1.11M Members

Apache2 CGI 403 Forbidden

 
0
 

Hello! So I decided I wanted to try some CGI... and it's not working out well at the moment, any help would be greatly appreciated!

So essentially in my 000-default virtual host config file I have this:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/apott/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/apott/www>
                Options +ExecCGI Indexes FollowSymLinks Includes
                AddHandler cgi-script .cgi .d .py
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The CGI scripts I'm trying to use are kept in the specified DocumentRoot

So currently whenever I go to a CGI script I just get a 403 forbidden error, but if I put the +ExecCGI here: Options +ExecCGI Indexes FollowSymLinks Includes at the end of the line I get a 500 server error, if that means anything to anyone.

Any help will help tons! Thanks in advance.

 
0
 

Hi, the config seems fine, so it can be a permission issue or the mime-type (each CGI needs the mime-type declaration at the top of the script), check this link for more information: http://httpd.apache.org/docs/2.2/howto/cgi.html#writing

Also, check Apache error logs to get more details about the issue. Hope it helps.

 
0
 

I have declared the MIME type as well as changing permissions of the files (I have tried chmod a+x and chmod +x).
This was in the error log, not sure if it's of any signifigance:

[Thu Jul 18 18:52:00 2013] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /home/apott/www/D/test.py, referer: http://localhost/D/ 
 
1
 

If I change +ExecCGI to ExecCGI it gives a 500 internal server error and the error.log says:

[Thu Jul 18 19:20:25 2013] [error] [client 127.0.0.1] (13)Permission denied: exec of '/home/apott/www/D/test.py' failed, referer: http://localhost/D/
[Thu Jul 18 19:20:25 2013] [error] [client 127.0.0.1] Premature end of script headers: test.py, referer: http://localhost/D/ 

EDIT:
I got it working with Python now, I can figure the rest out.

Question Answered as of 1 Year Ago by cereal
Isn't it about time forums rewarded their contributors?

Earn rewards points for helping others. Gain kudos. Cash out. Get better answers yourself.

It's as simple as contributing editorial or replying to discussions labeled or OP Kudos

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article