Search code examples
perlapachewebcgiosx-mountain-lion

Forbidden: CGI Programming With Apache and Perl on Mac OS X


I'd like to do the CGI programming with Apache and Perl in Max OS X 10.8.5. I followed the guide : CGI Programming With Apache and Perl on Mac OS X. The steps are:

  1. edit /etc/apache2/httpd.conf, uncomment the following:

    AddHandler cgi-script .cgi  .pl

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
  1. edit /etc/apache2/userName.conf:


Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI
DirectoryIndex index.html index.cgi
AllowOverride None
Order allow,deny
Allow from all

  1. start apache:

sudo apachectl restart
  1. put a cgi file into the folder: ~/Sites. I have update the privilege of test.cgi:

sudo chmod 755 test.cgi

That's all I have done. However, when I visit : ht tp://localhost/~userName/test.cgi, the result:

Forbidden

You don't have permission to access /~username/test.cgi on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I try to put a html into the ~/Sites, and it can be shown correctly. It seems there is something wrong with the cgi configurations, but I can't find it. Could anyone give some guides?

thanks!


Solution

  • The steps in CGI Programming With Apache and Perl on Mac OS X are correct. If restarting apache does not work, restart the mac! And Now I can use the cgi!