0

I have a file test.py in my cgi-bin folder for apache. The file looks like this:

#!/usr/bin/python
print("Content-type: text/html\n\n")
print("Hello world!")

Then, if I go to www.<mywebsite>.com/cgi-bin/test.py, the page successfully shows Hello world!

But, if I change my header line in my python script to

#!/home/kalaracey/python2.7/bin/python

when I navigate to www.<mywebsite>.com/cgi-bin/test.py, I get a Error 500 Internal Server error. Any ideas?

I have done sudo chmod 755 test.py and can call it with just ./test.py with both versions of the header line.

EDIT: Per @Anony-Mousse 's comment, here's the Apache error_log that applies:

[Wed Jul 11 17:33:40 2012] [error] [client <ipaddress>] (13)Permission denied: exec of '/var/www/cgi-bin/test.py' failed
[Wed Jul 11 17:33:40 2012] [error] [client <ipaddress>] Premature end of script headers: test.py
2
  • What does the apache error log say? Commented Jul 11, 2012 at 17:27
  • @Anony-Mousse I've added the two lines of the error_log that apply; it looks like it's a permissions error? Commented Jul 11, 2012 at 17:38

1 Answer 1

1

Does the web server user have access rights to your custom python installation?

If it cannot execute /home/kalaracey/python2.7/bin/python it cannot execute your script.

Make you have chmod -R go+rX /home/kalaracey/python2.7 and chmod go+x /home/kalaracey/python2.7/bin/python.

Sign up to request clarification or add additional context in comments.

2 Comments

I executed both of those commands but still nothing. Any ideas? My permissions for ~/python2.7/ are drwxr-xr-x; ~/python2.7/bin is drwxr-xr-x; and ~/python2.7/bin/python is -rwxr-xr-x
Actually, I realized that the permissions for home/kalaracey (i.e., ~) are just drwx------. Changing permissions for it via chmod -R go+x /home/kalaracey allowed the script to run. Thanks for all your help @Anony-Mousse!

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.