Left Menu









Howto compile Apache HTTP from source and run it for first time

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 has been the most popular web server on the Internet since April 1996.
The latest Version at this time is 2.2.


NOTE: The Apache httpd server is available in the official three of many distributions :


Ubuntu/Debian : apt-get install <package>
Gentoo : emerge <package>
Sabayon : equo install <package>
ArchLinux : pacman <package>
and so on ... it depends on the distribution

If you already installed it from the official three, it depends on the distribution, check HERE



If you still decide to compile it from source here is the way ... :

1. Download Apache :

$ links http://httpd.apache.org/download.cgi  
If you do not  have "links", try "lynx"



2. Unpack the archive

$ tar xvf httpd-2.2.14.tar.gz

3. Enter (use "cd") the directory

$ cd http-2.2.14

4. Configure it for your platform and requrements :

$ ./configure  --prefix=$HOME/apache

To configure the source tree using all the default options, simply type ./configure. To change the default options, configure accepts a variety of variables and command line options.
The most important option is the location --prefix where the Apache HTTP Server is to be installed later, because Apache HTTPd has to be configured for this location to work correctly. More fine-tuned control of the location of files is possible with additional configure options. Also at this point, you can specify which features you want included in Apache HTTPd by enabling and disabling modules. The Apache HTTP Server comes with a Base set of modules included by default. Other modules are enabled using the --enable-module option, where module is the name of the module with the mod_ string removed and with any underscore converted to a dash. You can also choose to compile modules as shared objects (DSOs) -- which can be loaded or unloaded at runtime -- by using the option --enable-module=shared. Similarly, you can disable Base modules with the --disable-module option. Be careful when using these options, since configure cannot warn you if the module you specify does not exist; it will simply ignore the option.


5. Install it

By default, make install will install all the files in /usr/local/apache2/bin, /usr/local/apache2/lib etc. You can specify an installation prefix other than /usr/local/apache2 using --prefix, for instance --prefix=$HOME/apache. This will install it under "/home/kickar/apache"

$ make && make install

6. Edit httpd.conf according to your needs.

$ nano $HOME/apache/conf/httpd.conf

You might have to add a variable "ServerName", right now we added :

ServerName www.linnewbies.com:80

7. Let's start it

$ /home/kickar/apache/bin/apachectl -k start

8. Check if It Works :

Open up a browser and navigate to http://localhost , or you can use curl, links or lynx if you dont have X installed :

$ curl http://localhost

<html><body><h1>It works!</h1></body></html>

Thats about it. Now is time for adding Virtual Hosts : This example is with Named Based VHosts

1. Edit your conf/httpd.conf with addid the following (Edit according to your needs)

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.test.com
ServerAlias test.com
DocumentRoot /home/kickar/test
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog /home/kickar/log/test_access_log combined
</VirtualHost>


NOTE: The Default host may dissapear, if so add a vhost entry for it, with the same ServerName and DocumentRoot and you can change *:80 to whatever port you would like to access your vhost.


2. Edit your /etc/hosts file so it can point to your vhost. Example :

127.0.0.1       localhost test.com

3. Reload apache and access it via Web Browser and Enjoy


If you have any question please refer to our FORUM



Delicious de.li.cio.us


|Home | LinuXchange| Updates | Contact Us | About The Project | Unique Visitors| Sponsorship|