Thursday, February 23, 2012 - 04:56
FeedBurner  RSS 2.0 Feed  Follow Me On Twitter  Save On Delicious

Modifying The Apache 2.2 Httpd Conf File

Guide for modifying / adjusting the Apache 2.2 httpd.conf file.

The Apache httpd.conf file works “Out Of The Box” so to speak, but I advise to adjust it for your specific needs. If you are new to Apache this guide will show you the minimum adjustments needed.

Now there are some minor changes in apache 2.2 compared to apache 1.3. The httpd.conf file has been broken into smaller parts pr. default. It has always been possible to do that on apache 1.3 as well although it was not the default.

So now you need to get used to that the basic httd.conf file resides in the directory “/usr/local/etc/apache22″ and the rest of the functionality is broken down and resides in a directory called “extra” residing in the apache22 directory i.e. here “/usr/local/etc/apache22/extra”.

It is possible to put the content of all the files residing in the “extra” directory and place them directly inside the httpd.conf file. In this guide I will refer to the original layout with the extra files residing in the “extra” directory.

As root
cd /usr/local/etc/apache22
vi httpd.conf

Now some browsers may have trouble reading some CMS systems CSS files correctly you can choose to create and modify a .htaccess file every time or just add the entry below and it will always work. you need to add the following just above the line where it reads AddType application/x-gzip .tgz

Find the following line
#AddType application/x-gzip .tgz

Add this line below
AddType text/css .css

So it looks like this
#AddType application/x-gzip .tgz
AddType text/css .css

Find the following line and replace it with a real address
ServerAdmin you@example.com

Find the following line and replace “www.example.com” with a real domain
ServerName www.example.com:80

Next we will tell apache what type of pages it is serving

Find the following line
DirectoryIndex index.html

Change it so it looks like this
DirectoryIndex index.php index.html index.htm default.htm default.html

Apache 2.2′s configuration file comes split up in several smaller files in a directory called “extra” this would normally be in /usr/local/etc/apache22 we need to make some changes to a few files in there.

As root
cd /usr/local/etc/apache22/extra
vi httpd-default.conf

The changes below are optional although I highly recommend setting ServerSignature to Off and ServerTokens to Prod.

Optional find the following lines
ServerTokens Full
ServerSignature On

Optional change these so they look like this
ServerTokens Prod
ServerSignature Off

If you want to reverse the IP numbers as they arrive in your log files you need to change HostnameLookups Off to On.

As root
vi httpd-default.conf

Optional find the following line
HostnameLookups Off

Optional change it so it looks like this
HostnameLookups On

In order for the changes made to the files in the “extra” directory to be loaded every time you start or restart apache we need to adjust the httpd.conf file accordingly.

As root
cd /usr/local/etc/apache22

Find the following line
#Include etc/apache22/extra/httpd-default.conf

Remove the “#” so it looks like this
Include etc/apache22/extra/httpd-default.conf

If you run Virtual Hosts and would like to keep them in a separate file remove the # on the following line in httd.conf

Find the following line
#Include etc/apache22/extra/httpd-vhosts.conf

Remove the “#” so it looks like this
Include etc/apache22/extra/httpd-vhosts.conf

As root
apachectl restart
Related Guides  Links  Requirements