Installing APACHE Web Server

Download Apache

To get Apache, obviously you have to go to their site at  http://www.apache.org/.  Proceed to the downloads (http://www.apache.org/dist/) section or find the closest Apache mirror to you  (http://www.apache.org/dyn/closer.cgi) to get your copy. For the Unix version of Apache, you would go through the well-named list of files and grab the gzipped copy (apache_1.3.9.tar.gz)

Decompress

Since you downloaded a tar ball, you have to decompress it. Simply type

tar -zxf apache_1.3.9.tar.gz

A directory called apache_1.3.9 will be created. You will have to go to this directory to proceed to the next step and compile the source code.

Compile the Source

Once in the apache_1.3.9 directory, from the prompt type

 ./configure

This will create a makefile with the default configuration. To change the configuration, you must edit apache_1.3.9/src/Configuration.tmpl before running configure. Once configured type make to compile the server, and make install to put it in the proper directories.

 

Start using Apache 

To startup Apache in Unix, all you have to do is run httpd. This would look something like this

/usr/local/apache/httpd

but this also depends on where you installed the binary. It will automatically use the configuration file it created on compilation called httpd.conf. If you would like to use another configuration file, you can use the -f argument.

Ex. /usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf

Note::  In the CSA server (people.csa.iisc.ernet.in) you can view the file at /home/web/apache/bin/ (at the deimos machine)

Start/Stop the Server

The Apache distribution does come with another method of starting/stopping/restarting Apache. The script is called apachectl. In the Apache src directory (apache_1.3.9/src), type

make

at the prompt. You will see a few more files compiled. After make is done, go to the support directory (apache_1.3.9/src/support), where you will find a bunch of new files created. There are a few helper scripts made now, including apachectl, htpasswd (used to make Apache passwords for protected directories). There are a few other files, but these files are the most important. Make a copy of these three files to your Apache binary directory. If you did not change the default settings, this would be located at /usr/local/apache/bin/.

To start the server, use

/usr/local/apache/bin/apachectl start

There is also

/usr/local/apache/bin/apachectl stop

and

/usr/local/apache/bin/apachectl restart available, obviously to stop or restart the server. I

n CSA people Web Server the same can be viewed at /home/web/apache/bin/

Start Apache at Boot

To have Apache start upon booting up your system, make a copy of apachectl in your startup directory (typically /etc/rc.d/init.d ) Check it all out to make sure everything is working. From your browser, check out http://localhost/ right afterwards.

 

CONFIGURE

Now comes the most crucial part of a server. It is the configuration of the same as per your requirements. Though it is generally thought to be scary to edit a configuration file for anything, for Apache, it doesn't have to be. The configuration can be found in the apache_1.3.9/conf/ directory.

Firstly, there is httpd.conf, which contains directives and configurations relating to the operation of the server as a whole.

Next on the list, there is srm.conf. This file contains the configurations for the management of resources in the filesystem, such as aliases, directory indexes, etc.

Lastly, access.conf. This file contains information on access control in whatever directories you please.

When you first install Apache though, the files are not named exactly like this, they seem to be named name.conf-dist. This means it is the distribution copy of the file.You need to rename the distribution files as httpd.conf.