I have a c-compiled CGI application that I need to execute from the DocumentRoot of my Apache server. The CGI file is called index.cgi and is located at /usr/lib/cgi-bin/index.cgi.

I have the following Directory definition

<Directory "/usr/lib/cgi-bin/">
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    AllowOverride None
    Order allow,deny
    Allow from all
    DirectoryIndex index.cgi 

I have the following VirtualHost setting:

<VirtualHost *:80>  
    ServerAdmin webmaster@localhost
    DocumentRoot /usr/lib/cgi-bin
#   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    ErrorLog /var/log/apache2/error.log     
    LogLevel warn   
    CustomLog /var/log/apache2/access.log combined


If I go to or I get prompted to download the index.cgi file, however if I enable the ScriptAlias in the vhost configuration block and go to I see the output of my CGI application.

I had originally solved this problem with mod_rewrite, however that worked on my test system the target (embedded) doesn't have that module available so I'm looking at another route (again).

1 Answer 1


You need to specify the cgi handler for the file if you do not use ScriptAlias. IN the directory section, add something like

AddHandler cgi-script .cgi

This is what the documentation says:

Any file that has the handler cgi-script will be treated as a CGI script, and run by the server, with its output being returned to the client. Files acquire this handler either by having a name containing an extension defined by the AddHandler directive, or by being in a ScriptAlias directory.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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