1,105,295 Community Members

Apache2 CGI 403 Forbidden

Member Avatar
NardCake
Posting Pro in Training
412 posts since Oct 2012
Reputation Points: 30 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 9 [?]
 
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.

Member Avatar
cereal
Posting Virtuoso
1,710 posts since Aug 2007
Reputation Points: 461 [?]
Q&As Helped to Solve: 345 [?]
Skill Endorsements: 44 [?]
 
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.

Member Avatar
NardCake
Posting Pro in Training
412 posts since Oct 2012
Reputation Points: 30 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 9 [?]
 
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/ 
Member Avatar
NardCake
Posting Pro in Training
412 posts since Oct 2012
Reputation Points: 30 [?]
Q&As Helped to Solve: 30 [?]
Skill Endorsements: 9 [?]
 
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 8 Months Ago by cereal
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article