Python Installation

1) Download and extract Python:

cd /usr/local/src
wget http://apache.dataphone.se/httpd/modpython/mod_python-3.3.1.tgz
tar zxvf mod_python-.3.3.1tgz

2) Configure & install Python

cd mod_python-3.3.1
./configure –with-apxs=/usr/local/apache/bin/apxs (check where your apxs is by typing: locate apxs)
make
make install

3) Configure Apache

pico -w /usr/local/apache/conf/httpd.conf
Locate your LoadModule – section by pressing CTRL-W and typing “LoadModule”. Add the following line under the others:
LoadModule python_module libexec/mod_python.so

Now locate your AddModule – section by pressing CTRL-W and typing “AddModule”. Add the following line under the others:
AddModule mod_python.c

Installation and Configuration complete.

4) We need to test python script on the server.

Go to any accounts on the server
create testpython.py and put below code
—–
def handler(req):
req.send_http_header()
req.write(“Hello World!”)
return apache.OK
—–

Open .htaccess file and put below code.
—-
AddHandler python-program .py
PythonHandler testingpython
PythonDebug On
—-

Now restart Apache service and test your script.



Both comments and pings are currently closed.

Comments are closed.