Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to run cgi scripts from other locations besides /var/www/cgi-bin, examples:


How do I go about configuring the server to do this?

EDIT: This is to run cgi scripts from a website on my personally hosted webserver.

share|improve this question

ScriptAlias is your uncle.


Description:    Maps a URL to a filesystem location and designates the target as a CGI script
Syntax: ScriptAlias URL-path file-path|directory-path
Context:    server config, virtual host
Status: Base
Module: mod_alias

The ScriptAlias directive has the same behavior as the Alias directive, except that in addition it marks the target directory as containing CGI scripts that will be processed by mod_cgi's cgi-script handler. URLs with a case-sensitive (%-decoded) path beginning with URL-path will be mapped to scripts beginning with the second argument, which is a full pathname in the local filesystem.

ScriptAlias /cgi-bin/ /web/cgi-bin/

A request for would cause the server to run the script /web/cgi-bin/foo. This configuration is essentially equivalent to:

Alias /cgi-bin/ /web/cgi-bin/
<Location /cgi-bin >
SetHandler cgi-script
Options +ExecCGI
share|improve this answer
Is there a specific configuration file I'm supposed to be looking at? – Mechaflash Oct 21 '11 at 16:36
I edit httpd.conf, there's the default entry of: /cgi-bin/ "/var/www/cgi-bin/" I create an additional entry below it: /cgi-bin/ "/var/www/folder1/cgi-bin/" I restart the httpd and I still do not have access to my cgi script. However it still works if ran from /var/www/cgi-bin/ – Mechaflash Oct 21 '11 at 16:43
up vote 1 down vote accepted

There are two ways to accomplish this:

1) Setup virtualhosts, and under each virtualhost, specify ScriptAlias /cgi-bin/ "/your/location"

2) Create sub-folders under /var/www/cgi-bin and use the sub-folders to link to them, however with this method, you cannot leave the /var/www/cgi-bin directory tree.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.