Apache - Important settings in httpd.conf


To make server-side-includes and CGI scripts work on Apache (which by default, they don't seem to), be sure to check the following settings in httpd.conf.  If you're running virtual servers, be sure to check whether you need similar settings for each virtual server (IIRC, there are two places that you need to check/modify when dealing with virtual servers).

Enable server-side-includes:

# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    Options Includes Indexes FollowSymLinks MultiViews ExecCGI

--skip--

# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml

--skip--

# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index.  Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
    DirectoryIndex index.shtml index.php index.html
</IfModule>

Enable CGI scripts:

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
    ScriptAlias /cgi-bin/ "/opt/apache/cgi-bin/"

#
# "/opt/apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#

    <Directory "/opt/apache/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>

--skip--

# To use CGI scripts:
#
AddHandler cgi-script .cgi