Reputation:
Here's the Python script itself (test.py):
#!/Users/misha/AppData/Local/Programs/Python/Python35-32
print("Content-Type: text/html\n")
print("\n\n")
print("<h1>Test</h1>")
I have this in my Apache's configuration file httpd.conf:
<Directory "c:/Apache24/htdocs">
...
...
Options Indexes FollowSymLinks ExecCGI
...
...
</Directory>
AddHandler cgi-script .cgi .py
I restart Apache--everything else works just fine, but when I try to point to my Python test file in my browser, the server throws an Internal Server Error at me.
Here's my Apache's latest log file entries (I have edited them a little bit just for readability's sake):
(localhost-error.log)
[Thu Feb 11 14:24:39.357362 2016] [cgi:error] [pid 16872:tid 1028]
(OS 5)Access is denied. : [client 127.0.0.1:54957] AH01223:
couldn't spawn child process: C:/Apache24/htdocs/test.py
(localhost-access.log)
127.0.0.1 - - [11/Feb/2016:14:24:39 -0800] "GET /test.py HTTP/1.1"
500 528
I don't even know what to do now.
Upvotes: 1
Views: 2193
Reputation: 2306
Make sure you put shebang line in your code.
And check your script permissions. It should be executable.
To change file permission to executable in Linux: chmod +x filename.py
I don't know about windows.
Upvotes: 0
Reputation: 605
It may be that Apache can't find the python interpreter. You should make sure the shebang in your file is correct. Test if you can run the file from a different folder.
Upvotes: 2