Friday, June 19, 2009

Howto install python and mod_python on linux

Installing Python

If you want to install it onto custom directory, for example like /home/you/opt/Python

Get python sources from python.org

Untar it.

./configure --prefix=/home/you/opt/Python --exec-prefix=/home/you/opt/Python --enable-shared

make; make install;

Installing mod_python

Get mod_python from here http://httpd.apache.org/modules/python-download.cgi

Untar it.

./configure --prefix=/home/you/opt/mod_python --exec-prefix=/home/you/opt/mod_python --with-apxs=/home/you/opt/httpd/bin/apxs --with-python=/home/you/opt/Python/bin/python

# because normal 'make install' needs 'su' access,
make; make install_dso; make install_py_lib

add below configurations into httpd.conf

LoadModule python_module modules/mod_python.so

<Directory [absolute path]>
AddHandler mod_python .py
PythonHandler test
PythonDebug On
</Directory>
Restart httpd. It'll works.

No comments:

Post a Comment