Guidelines for setting up a Python file at DreamHost

All Python CGI scripts on DreamHost must:

  • end in ".py" (NOTE: ".cgi, .fcgi" works as well).
  • have #!/usr/bin/python in the very first line of the file (NOTE: #!/usr/bin/python2.x or #!/usr/bin/env python2.x will work as well).
  • be marked as executable: chmod 755.
  • use UNIX style newlines, not Windows.
  • If you want to view printed output from your Python code, you must print "Content-type: text/html\n\n" as the first line of output.
  • If you don't want .py files to be executed by Apache add "RemoveHandler .py" command to your .htaccess file.
  • Additionally, on DreamHost, all Python CGI scripts AND their immediate parent directory must have their Unix user and Unix group left set to your domain's Unix user AND that user's DEFAULT Unix group (otherwise you will get an internal server error from Apache's suexec).

See also

Did this article answer your questions?

Article last updated .