0

Trying to configure apache on my laptop to execute a python script for a small assignment:

  • I've created a /scripts folder in root and granted it all permissions 777.
  • In my virtual hosts file I have added ScriptAlias /scripts/ /scripts/
  • Added directory handle also in my conf file:

    Options +ExecCGI FollowSymLinks Indexes MultiViews AllowOverride All Order allow,deny Allow from all AddHandler cgi-script .py

The script I'm trying to run is (a sample python test script):

#!/usr/bin/python

print "Content-type: text/html"
print
print "<pre>"
import os, sys
from cgi import escape
print "<strong>Python %s</strong>" % sys.version
keys = os.environ.keys()
keys.sort()
for k in keys:
    print "%s\t%s" % (escape(k), escape(os.environ[k]))
print "</pre>"

When I access it via http://127.0.0.1/scripts/results.py I get an Internal Server Error and in my error log I get the following error:

[Mon Dec 05 20:58:30 2011] [error] [client 127.0.0.1] (2)No such file or directory: exec of '/scripts/result.py' failed

[Mon Dec 05 20:58:30 2011] [error] [client 127.0.0.1] Premature end of script headers: result.py

Apache does have suexec module loaded from what I've found when running apachectl -v, and suspect that this may have something to do with the problem.

Also running /usr/bin/python /scripts/result.py executes fine, but since apache runs under a different user guess this doesn't mean much.

Also I'm running this on OSX Lion, and I wasn't able to find how to run the script from cli as apache, during my debugging.

Any help would be appreciated.

0

1 Answer 1

0

I don't have access to OSX, but I'd probably try something like this:

ScriptAlias /cgi-bin/ "/scripts/"
<Directory "/scripts">
    Options +ExecCGI FollowSymLinks Indexes MultiViews
     AllowOverride All 
     Order allow,deny
     Allow from all
     AddHandler cgi-script .py
</Directory>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.