Search This Blog

Friday, February 18, 2011

Apache – enable python script support/python module. mod_python

 

The installation procedure on Windows is like this:

  1. Install Apache server from httpd-2.2.17-win32-x86-openssl-0.9.8o.msi
  2. Install python 2.5 from python-2.5.2.msi
  3. Install mod_python-3.3.1.win32-py2.5-Apache2.2.exe showing it apache main directory (in my case it was: c:\Program Files\Apache Software Foundation\Apache2.2\modules\)
  4. If step 3 won’t work for you, do this step as well. Copy mod_python.dll and mod_python.so to: $apache$/modules/
    (in my case it was: c:\Program Files\Apache Software Foundation\Apache2.2\modules\)
  5. Copy all the files from mod_python-3.3.1.tar\mod_python-3.3.1\lib\python\mod_python\*.* to c:\Python25\Lib\mod_python\
    (there are 12 *.py files in there)
  6. Change httpd.conf

add this line in # Dynamic Shared Object (DSO) Support section:
LoadModule python_module modules/mod_python.so

add this piece of code in two sections (#ScriptAlias: and in IfModule cgid_module section:

    <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/python">
       AddHandler mod_python .py
       PythonHandler test
       PythonDebug on
    </Directory>

example httpd.conf can be found in my package.

   7.  Create a file for testing: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/python/test.py

test name is important as we defined the name earlier in “PythonHandler” section!!!!

package with all the files needed:

http://sites.google.com/site/bkosarzyckiaboutme/ApachePythonPackage.rar

No comments:

Post a Comment

If you like this post, please leave a comment :)