Your Ad Here
 

Minimal Apache Web Server httpd.conf configuration file

devans's picture
Your rating: None Average: 4.5 (4 votes)

Following an install of Apache on Windows you are faced with the somewhat daunting process of wading through the httpd.conf file and deciding upon what is required for your particular circumstance.

As a matter of course, I typically save the default httpd.conf file to another name and use a vastly trimmed down variant in place thereof.

What I have pasted below represents such an example and trims the config file to a much more manageable 55-lines of code having stripped the unnecessary elements along with all of the comments.


PidFile logs/httpd.pid
Listen 80
ServerName localhost
ServerTokens Prod
ServerSignature Off
FileETag None
UseCanonicalName Off
HostnameLookups Off
AddDefaultCharset IS-8859-1
ServerAdmin webadmin@localhost
ServerRoot "c:/www/Apache22"
DocumentRoot "c:/www/vhosts/localhost"
Timeout 45
KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 100
ThreadsPerChild 150
MaxRequestsPerChild 1000
ErrorLog logs/error.log
LogLevel error
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access.log combined
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule dir_module modules/mod_dir.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
DefaultType text/html
DirectoryIndex index.html
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>
AccessFileName .htaccess
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<Directory "c:/www/vhosts/localhost">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
TraceEnable Off
<IfModule mime_module>
TypesConfig conf/mime.types
</IfModule>

It should be noted that when modifying this for your own purposes, remember to pay special attention to the file location references throughout and align these to your own directory structure and configuration for Apache.

This configuration was designed for use with an Apache 2.2 release but should also work with the Apache 2.0 version too.

Also, while I have directed this configuration toward Microsoft Windows, there is no reason why, with the file modifications already referenced above, that this would not work for Apache installations on other operating systems too.

I'd love to hear other suggestions regarding optimizing this code even further or feedback on how such a configuration helped you out in some way.

Enjoy!

Post new comment

The content of this field is kept private and will not be shown publicly.
 
  • Allowed HTML tags: <a><em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Testing for human visitors.