apache configration

cgi scripts

These can be written in any language, but in most cases perl is used. See ‘testing’ to get an idea of the requirements a cgi script must meet independant of its language.
In order to run scripts apache has the mod_cgi script, which can be an external module or compiled in. If it is an external module it must be activated like so:

We also need to configure where cgi scripts are allowed to be executed. the criteria can be a path or a file extension and if you have an AllowOverride All directive in your httpd.conf you can also use a .htaccess-file to tell apache which files are cgi scripts. In the first case this is done by defining a ScriptAlias, a path in which only cgi-scripts are allowed to be, because anything will get exected. I do not like this at all.
You better specify AddHandler cgi-script pl cgi in a .htaccess in the folder where your scripts are or in the main configuration for that folder, which might look something like this:


Apache expects cgi-scripts to return a http header. To test your configuration you can write a program in any language which returns:

and append its extension to the list of cgi scripts, e.g. using a minimal .htaccess-file:

I like having these scripts laying around for testing after a set up: