Friday, September 13, 2013

Configuring Apache server from source on Ubuntu server

How to build Apache server from source on Ubuntu


The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
Apache httpd has been the most popular web server on the Internet since April 1996, and celebrated its 17th birthday as a project this February.

On a freshly installed Ubuntu 12.04 server we are going build the source file for the Apache web server. First thing we should do is to get the build-essential packet.

root@ubuntu-2:/# sudo apt-get install build-essential

Next thing is to get the source files. I prefer to keep the source file on the other location that is different that the home directory. So we will create a new folder. Under the root folder create a src folder.

root@ubuntu-2:/# mkdir src
root@ubuntu-2:/# cd src

Some browser support web page compression so we should install the Zlib. This is an opensource compression library.

root@ubuntu-2:/src# wget http://www.zlib.net/zlib-1.2.8.tar.gz
tar xvfz zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --prefix=/usr/local
make
sudo make install

Now we can download the Apache web  server source files.

cd..
wget http://download.nextag.com/apache//httpd/httpd-2.4.6.tar.gz


Extract the sources and enter the folder where they are located.

tar xvfz httpd-2.4.6.tar.gz
cd httpd-2.4.6

Next step is to configure the apache source files.

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all
--enable-deflate --enable-proxy --enable-proxy-balancer --enable-proxy-http


If you ran on a problem with missing libraries, one can install them once more.

sudo apt-get install libapr1-dev libaprutil1-dev

The final step is to start the apache service:

sudo /usr/local/apache2/bin/apachectl start

Open up a browser and type in the external IP of the server. You should get this message:

It works!

The next step is to stop the apache we server and make an init script to run automatically.

sudo /usr/local/apache2/bin/apachectl stop
sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apachectl
sudo chmod +x /etc/init.d/apachectl

sudo /usr/sbin/update-rc.d apachectl defaults 


To test the startup scripts you should restart the server and then try to browse a page. If it does not work, you should check the logs folder inside the apache folder.

That is all for now.

Feel free to comment.

No comments:

Post a Comment