Home > linux, software > Apache with Python on Linux in 2 minutes

Apache with Python on Linux in 2 minutes

September 20th, 2011 Leave a comment Go to comments

After 2 hourse of googleing and reading outdated threads, I got it working and want you to save time.

  1. Install Apache2 and Python
  2. CGI-path is /usr/lib/cgi-bin so this is where to put your Python scripts
  3. To use the scripts in your HTML files you have to prefix the path to the .py files with /cgi-bin/
  4. To generate proper output the first print call in your script has to be
    print "Content-type: text/html\n\n"
  5. With the python module cgi you are able to access content of the calling HTML form
  6. If something went wrong /var/log/apache2/error.log is your friend!

For more information see: http://httpd.apache.org/docs/2.0/howto/cgi.html But not everything in there worked for me…
For usage of Pythons CGI module see: http://docs.python.org/library/cgi.html

Have Fun!

Categories: linux, software Tags: , ,
  1. September 20th, 2011 at 16:34 | #1

    CGI, haven’t heard that in a while…. Those good old times when the P in LAMP stood for Perl …

  1. No trackbacks yet.