Reputation: 755
I'm having trouble accessing a really simple cgi script that I wrote in python and am having too much trouble finding the solution. I have a feeling that it will be quite an easy fix, but I can't figure it out myself.
url: localhost/cgi-bin/test.cgi (I've also tried naming it test.py) The error that I'm getting is a simple 404, which I thought the ScriptAlias below would take care of. Further, if I try to access localhost/cgi-bin/ I get a 403: Access Denied. I tried resetting permissions (I'm aware it's stupid) to 777, but no better results.
/etc/apache2/httpd.conf (no special edits to default /etc/apache2/apache2.conf):
ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/
<Directory /usr/local/apache2/cgi-bin/>
Options +ExecCGI
AddHandler cgi-script .cgi .py
</Directory>
/usr/local/apache2/cgi-bin:
.
└── test.cgi
test.cgi:
#!/usr/bin/python
import cgi
#cgi.test()
print 'Content-type: text/html\n\n'
print 'test'
Further, I've also restarted apache2 after changing httpd.conf file. I can't think of anything else to include besides that I've already looked at: ScriptAlias configuration not working in apache2 but I don't understand what global the author is referencing. I feel pretty strongly that it's an error in one of my configurations, but it seems like the code is pretty straight forward.
If anyone can help me over this hump of stupid, I'd be much appreciative.
Edit:
Error log:
--clip--
[Thu Sep 26 23:34:59 2013] [error] [client 127.0.0.1] script not found or unable to stat: /usr/lib/cgi-bin/test.cgi
[Thu Sep 26 23:42:08 2013] [error] [client 127.0.0.1] script not found or unable to stat: /usr/lib/cgi-bin/test.cgi
System info:
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
uname -a
Linux #### 3.2.0-39-generic #62-Ubuntu SMP Thu Feb 28 00:28:53 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
I think I've found the culprit:
/etc/apache2/sites-enabled/000-default:
1 <VirtualHost *:80>
2 ServerAdmin webmaster@localhost
3
4 DocumentRoot /var/www
5 <Directory />
6 Options FollowSymLinks
7 AllowOverride None
8 </Directory>
9 <Directory /var/www/>
10 Options Indexes FollowSymLinks MultiViews
11 AllowOverride None
12 Order allow,deny
13 allow from all
14 </Directory>
15
16 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
17 <Directory "/usr/lib/cgi-bin">
18 AllowOverride None
19 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
20 Order allow,deny
21 Allow from all
22 </Directory>
Specifically line 16. I never thought to look in this directory
Upvotes: 0
Views: 3444
Reputation: 7292
Based on your error log, you are not editing the right config, or something. Notice it says /usr/lib/cgi-bin? Just for fun, if you copy your script to /usr/lib/cgi-bin, then try it, does it work? What OS is this apache installed on?
One more thing, is there another ScriptAlias in that config file somewhere? Maybe that is overwriting your mapping of /cgi-bin/?
Upvotes: 1