Cgi bin directory for each user in Apache

By | May 9, 2020

This page http://httpd.apache.org/docs/2.2/howto/cgi.html describes how to give each user his own cg-bin directory.
The following lines should be added to the Apache configuration file http.conf :

<Directory /home/*/public_html/cgi-bin>
Options ExecCGI
SetHandler cgi-script
</Directory>

Along with this there are some more points to be kept in mind. If you .htaccess file has a section like this :

<IfModule mod_rewrite.c>
	RewriteEngine on
	RewriteCond %{http_host} ^site.com [nc]
	RewriteRule ^(.*)$ http://www.site.com/\ [r=301,nc]
</IfModule>

then putting the cgi configuration will give this error :
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden
and the cgi files won't work. The solution is : Options +ExecCGI instead of Options ExecCGI

Also make sure that this line :
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
is commented, otherwise all request to www.site.com/cgi-bin would go to /var/www/cgi-bin instead of the user's cgi-bin directory.

If you get Internal Server Errors then try the solutions given on this page
http://encodable.com/internal_server_error/

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *