Enabling CGI on Apache 2.x


For more information, do ready up the Apache Tutorial: Dynamic Content with CGI which provides with a easy-to-read configuration if you wish to enable CGI on the Apache 2.x


The ScriptAlias directive tells Apache that a particular directory is set aside for CGI programs. Apache will assume that every file in this directory is a CGI program, and will attempt to execute it, when that particular resource is requested by a client.

ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/

Explicitly using Options to permit CGI execution

You could explicitly use the Options directive, inside your main server configuration file, to specify that CGI execution was permitted in a particular directory:

<Directory /usr/local/apache2/htdocs/somedir>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>

User Directories
To allow CGI program execution for any file ending in .cgi in users' directories with a cgi-bin extension, you can do the following:
<Directory /home/*/public_html/cg-bin>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>