Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 
</Directory>

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

</VirtualHost>

If I go to 127.0.0.1 or 127.0.0.1/index.cgi I get prompted to download the index.cgi file, however if I enable the ScriptAlias in the vhost configuration block and go to 127.0.0.1/cgi-bin/index.cgi 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).

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
That worked, thanks! –  user11888 Mar 18 '10 at 16:33
add comment

Your Answer

 
discard

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.