next up previous contents index
Next: Default Error Pages Up: Configuring Apache Previous: Configuring Apache   Contents   Index


Enabling User CGI

In order to allow users to use CGI in their public_html/ directories there are a few things that need to be changed from the default configuration. First let's open up the /etc/httpd/conf/httpd.conf file and see what the cgi-script handler looks like before and after. Find the line that looks like this:

#AddHandler cgi-script .cgi

Once you have the line, remove the pound sign (#) and decide which file extensions will be treated as CGI programs. Let's let the .pl extension also mean that the file is a CGI program. This is how the new line should look:

AddHandler cgi-script .cgi .pl

Okay, now that is done. Now we have to give the users rights to use CGI. The user HTML files are stored in a directory called public_html/. Find the place where the UserDir directories configuration is. Here is some example code you should find:

# Control access to UserDir directories.  The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/public_html>
#    AllowOverride FileInfo AuthConfig Limit
#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#    <Limit GET POST OPTIONS PROPFIND>
#        Order allow,deny
#        Allow from all
#    </Limit>
#    <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
#        Order deny,allow
#        Deny from all
#    </Limit>
#</Directory>

This is all commented and is not used, but it shows you basically what you need to do to configure user directories. Add code like this after the commented section:

<Directory /home/*/public_html>
    AllowOverride None
    Options ExecCGI Indexes Includes MultiViews SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

Once you finish the changes to the configuration file you will have to restart the server:

bash# /etc/rc.d/init.d/httpd restart

Now everything should be working. To test the page on Bob's website let's first change the permissions to his home directory, then create a public_html/ directory that he has rights to work in:

bash# chmod 711 /home/bob/
bash# mkdir /home/bob/public_html
bash# chown bob /home/bob/public_html

Once this is completed you can copy the CGI file /var/www/cgi-bin/dbitest.cgi to Bob's public_html/ directory and view it on the server at the URL: http://localhost/ bob/dbitest.cgi with a browser.


next up previous contents index
Next: Default Error Pages Up: Configuring Apache Previous: Configuring Apache   Contents   Index
Joseph Colton 2002-09-24