Python Web Programming Using Apache and mod-python
Python client/server programming with Apache and mod-python in Ubuntu 9.10.
1. Goto Synaptic Package Manager and install the following packages
a) apache2 [Apache Web Server]
b) libapache2-mod-python [Module for running Python Programs in Apache using mod-python ]
c) mysql-server [Mysql Database Server]
d) mysql-client [Mysql Client Terminal]
e) pyhton-mysqldb [Pyhton and Mysql database programming fucntions ]
f) python3,1 [optional but i strongly suggesting you to learn python 3.x ]
2. After Installation You can start , stop, or restart the apache and mysql server using this commands
# sudo su
# /etc/init.d/apache2 start/stop/restart
# /etc/init.d/mysqld start/stop/restart
3. If You want to create mysql database , use the given command
# mysql -u root -p
[Type the password which you had already given while installation of mysql server ]
4. Now Lets write one small web application , Open Your favorite editor vim , gedit or Eclipse
# sudo su
# vim first.py
#!/usr/bin/python3.1
print(“Content-Type: text/html\n”)
print(“<b>My First Web Application in Python<b>”)
Save and copy the file into
# cp first.py /usr/lib/cgi-bin
# chmod a+x /usr/bin/cgi-bin/first.py
5. Now Open your web browser and type the address like
http://localhost/cgi-bin/first.py
Thats it … Enjoy the power of Python programming …


Hello Antony
I want to know how to configure Apache with mod python in windows environment.
Download the following executable files
1. Apache 2 http://www.reverse.net/pub/apache/httpd/binaries/win32/apache_2.2.14-win32-x86-openssl-0.9.8k.msi
2. Mod Python http://mirror.cloudera.com/apache/httpd/modpython/win/3.3.1/mod_python-3.3.1.win32-py2.5-Apache2.2.exe
3. Python Interpreter http://python.org
Then configure the httpd.conf file , refer http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking this link for that .
Note : Copy python into Apache cgi-bin folder