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