Guide for modifying / adjusting the Apache 1.3 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.
As root
cd /usr/local/etc/apache
vi httpd.conf
Find this line and replace it with a real address
ServerAdmin you@your.address
Find the following line and replace “www.example.com” with a real domain.
ServerName www.example.com
We need to adjust how and what pages are being parsed.
Find the following lines
DirectoryIndex index.php index.html index.htm default.htm default.html
#
<IfModule mod_dir.c>
<IfModule mod_php3.c>
DirectoryIndex index.php3 index.html
</IfModule>
<IfModule !mod_php3.c>
<IfModule mod_php4.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule !mod_php4.c>
<IfModule mod_php5.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule !mod_php5.c>
DirectoryIndex index.html
</IfModule>
</IfModule>
</IfModule>
</IfModule>
Change these so they look like this
DirectoryIndex index.php index.html index.htm default.htm default.html
<IfModule mod_dir.c>
<IfModule mod_php3.c>
DirectoryIndex index.php index.php3 index.html index.htm default.html default.html
</IfModule>
<IfModule !mod_php3.c>
<IfModule mod_php4.c>
DirectoryIndex index.php index.html index.htm default.html default.html
</IfModule>
<IfModule !mod_php4.c>
<IfModule mod_php5.c>
DirectoryIndex index.php index.html index.htm default.html default.html
</IfModule>
<IfModule !mod_php5.c>
DirectoryIndex index.php index.html index.htm default.html default.html
</IfModule>
</IfModule>
</IfModule>
</IfModule>
The next to lines are not protecting your apache installation but it will prevent most people from seeing your apache’s version and production number. It will also hide the servername of the virtual host beeing served and the reference to the serveradmin to the particular page beeing served.
Find the following line
ServerSignature On
Change it so it looks like this
ServerSignature Off
ServerTokens Prod
You can perform reverse lookup of IP addresses in your log files if you like it’s done like this.
Optional find the following line
HostnameLookups Off
Optional Change it so it looks like this
HostnameLookups On
Next skip loading a lot of unneeded modules for php find the following lines.
Find the following lines
<IfModule mod_php3.c>
AddType application/x-httpd-php3 .php3
AddType application/x-httpd-php3-source .php3s
</IfModule>
<IfModule mod_php4.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
Change these so they look like this
# <IfModule mod_php3.c>
# AddType application/x-httpd-php3 .php3
# AddType application/x-httpd-php3-source .php3s
# </IfModule>
# <IfModule mod_php4.c>
# AddType application/x-httpd-php .php
# AddType application/x-httpd-php-source .phps
# </IfModule>
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phpt .html .css
AddType application/x-httpd-php-source .phps
</IfModule>
Netscape, Safari and a few other browsers can have some problems loading style sheets when running certain CMS systems or other applications. You can either write a .htaccess file and put it in the virtual host’s directory. Or you can fix this in the httpd.conf file like below.
Find the following line
AddType application/x-tar .tgz
Add this line just below that line
AddType text/css .css
So it looks like this
AddType application/x-tar .tgz
AddType text/css .css
We wan’t to run virtual hosts on this machine so find this line
Find the following line
# NameVirtualHost *:80
Remove the “#” So it looks like this
NameVirtualHost *:80
Let’s check the configuration (I know I’m using the full path to apachectl below this is a guide after all). You should be able to just type “apachectl configtest” without using the full path.
As root
/usr/local/sbin/apachectl configtest
Once the above command runs without errors we can start apache.
As root
/usr/local/sbin/apachectl start
Related Guides Links Requirements