Before compiling apache ensure that gcc is installed on your machine. To confirm just run,
gcc |
If you get the following output then gcc is installed on your machine
gcc: fatal error: no input files compilation terminated. |
In case if you get command not found then either you have to install gcc or it is already install you just have to set in your home path. By default in ubuntu gcc get installed at /usr/bin/gcc. So to set it in your PATH run,
export PATH=/usr/bin/gcc:$PATH |
Or you can add the above command in your profile
To install gcc on ubuntu run
sudo apt-get install gcc |
Now we will download and compile the apache on our machine. I am downloading apache in my home directory.
cd ~/myapps/ wget http://www.fightrice.com/mirrors/apache/httpd/httpd-2.2.21.tar.gz |
Extract the downloaded file
tar -zxvf httpd-2.2.21.tar.gz |
Now we will install apache in /home/vidyadhar/myapps/apache. You can give whatever directory you want by just modifying PREFIX attribute. For more options just run ./configure –help
cd httpd-2.2.21/ ./configure --prefix=/home/vidyadhar/myapps/apache |
Now we have to run make and make install to complete the procedure.
make make install |
After a successfull installation you have to modify httpd.conf file and do the basic settings.
In this installation we are going to run apache on 8081 port and we will be using our local user i.e vidyadhar to start and stop the apahce server. For server name we have to modify ServerName tag and have to put hostname over there.
Go to /home/vidyadhar/myapps/apache/conf
cd /home/vidyadhar/myapps/apache/conf |
Open httpd.conf file
vi httpd.conf |
Modify following settings
Listen 8081 User vidyadhar Group vidyadhar ServerName ubuntu.home.network:8081 |
Now we will start apache, to do the same run
cd /home/vidyadhar/myapps/apache/bin ./apachectl -k start |
To confirm apache is running on not, run following command
netstat -an | grep 8081 |
You should get output someting like this
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN |
Now just open your browser and enjoy your apache installation. The URL would be http://server_ip:8081/
