View Full Version : CGI conf settings for virtual hosts

12-20-2005, 05:48 PM
I want to give 3 of our virtual hosts the ability to run CGI in their own cgi-bin directories, like:
in addition to the stock

What is the correct way to set up the httpd.conf?


12-21-2005, 08:26 AM
I have always added the support for individual cgi directories by mimicing the set up for the main account inside the <VirtualHost> tags for each added virtual host. It has been a while so I'll try to remember what is needed. :)

<VirtualHost *>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example
<Directory "/var/www/example/cgi-bin">
Options ExecGGI
AddHandler cgi-script .cgi .pl .py .sh

There may be other things you end up wanting to add to the above example for each. If you look a the existing <Directory "/var/www/html"> it should give you an idea. There are entries on down for SSL that have to do also with cgi but I think they are covered but not sure. I would say start with the above and see where it takes you. Hope I am remembering everything right. :)

12-21-2005, 09:40 PM
I added:

<VirtualHost *>
ServerName me.com
ServerAlias www.mneme.com
ScriptAlias /cgi-bin/ "/var/www/me.com/cgi-bin/"
<Directory "/var/www/me.com/cgi-bin/">
Options ExecCGI
AddHandler cgi-script .cgi .pl
DocumentRoot /var/www/me.com/html

All is well, thanks.


12-23-2005, 07:51 AM
Great glad that worked for you. I am glad you picked up on adding the ScriptAlias. I had not realized that you where actually setting the DocumentRoot to /var/www/example/html. For those who do not realize why the ScriptAlias is needed it mimicks what is happening with your normal account and since the cgi-bin was created outside the public root Apache needed to be told where to find the cgi-bin. That is not the best explination but hopefully will help some folks. :)