Here are a few notes on things that can cause Server Error 500:
—
Permissions:
If you use chmod 777, 757 or 775 it causes the error.
See these links:
http://kb.site5.com/errors/error-500-internal-server-error/
http://kb.site5.com/ftp/chmod-overview/
—
Line endings:
Lines in your python file must use Unix line endings \n (0x0a).
Windows saves text files with a \r\n (0x0d 0x0a).
If you save in MS-Dos format from a windows editor you will have the wrong line endings.
To see if a file has the wrong line endings you can pipe it through xxd:
xxd test.py
You can fix the line endings by one of the methods below:
From Windows:
Wordpad: Save in non-MS-Dos format. Save As… | Save as type: Text Document (instead of Text Document – MS-DOS Format)
or
Notepad++: open the file then Edit | EOL Conversion | Unix/OSX Format
From Linux:
dos2unix test.py
or
vi test.py then (esc) :set fileformat=unix
—
The Content Line:
You need a line feed after the content line:
print (“Content-type: text/html\n”)
or
print (“Content-type: text/html”)
print (“”)
—
Python Syntax:
If you change your python interpreter to /usr/local/bin/python3.0 then scripts written in 2.x may fail (for example 3.x requires that print statements be in parentheses, etc.)
—
Mics.:
Be sure to check your error log to see what is causing the 500
http://kb.site5.com/control/siteadmin/siteadmin-error-log/
Check your script for syntax errors by running it in the shell: python test.py
Experiment with:
import cgitb
cgitb.enable()
—
Notice we specified the shell like this:
#!/usr/local/bin/python2.6
You can look and see what you have available like this:
Login to Site5 backstage
Site Admin to your site
Programming Center | Python
(You can also ls /usr/bin and /usr/local/bin to see what pythons are installed)