Warning: Table './wowtutorial/cache_page' is marked as crashed and last (automatic?) repair failed query: SELECT data, created, headers, expire, serialized FROM cache_page WHERE cid = 'http://www.wowtutorial.org/tutorial/238.html' in /usr/home/wowtutorial/public_html/includes/database.mysql.inc on line 135

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/wowtutorial/public_html/includes/database.mysql.inc:135) in /usr/home/wowtutorial/public_html/includes/bootstrap.inc on line 729

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/wowtutorial/public_html/includes/database.mysql.inc:135) in /usr/home/wowtutorial/public_html/includes/bootstrap.inc on line 730

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/wowtutorial/public_html/includes/database.mysql.inc:135) in /usr/home/wowtutorial/public_html/includes/bootstrap.inc on line 731

Warning: Cannot modify header information - headers already sent by (output started at /usr/home/wowtutorial/public_html/includes/database.mysql.inc:135) in /usr/home/wowtutorial/public_html/includes/bootstrap.inc on line 732
Install and Configure Mod_Python With Apache 2 | Wowtutorial

Search

User login

Poll

What is your favorite DB Server ?:
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 0 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

My YM

Author Information

sentono
Offline
Last seen: 1 day 9 hours ago
Joined: 09/21/2007

Alexa Rank

Who's online

There are currently 0 users and 68 guests online.
Home
warning: Cannot modify header information - headers already sent by (output started at /usr/home/wowtutorial/public_html/includes/database.mysql.inc:135) in /usr/home/wowtutorial/public_html/includes/common.inc on line 153.

Install and Configure Mod_Python With Apache 2

In this tutorial i assume you already have Apache 2.x , PHP 5.2.x and MySQL 5.x installed and running in your server.
If your server is a brandnew server. You need to follow this URL to install a complete Apache, PHP and MySQL

What is Mod_Python ?
Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python you can write web-based applications in Python that will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections and other data between hits and access to Apache internals.

Preparing to Install and configure Mod_Python
Login into your server with root access

#cd /root
#wget http://www.python.org/ftp/python/2.5/Python-2.5.tgz
#wget http://www.eu.apache.org/dist/httpd/modpython/mod_python-3.2.10.tgz
#wget http://downloads.sourceforge.net/project/flex/flex/flex-2.5.35/flex-2.5....

Extract Sources

#tar -zxvf Python-2.5.tgz
#tar -zxvf mod_python-3.2.10.tgz
#tar -zxvf flex-2.5.35.tar.gz

Install flex

#cd flex-2.5.35
#./configure
#make
#make install

Install Python

#cd Python-2.5
#./configure --enable-shared
#make
#make install

Try to access python with this command below :
#/usr/local/bin/python

if you can see a python prompt its mean you are successfully installed python on the server.
if you see any lib error or can't find lib. you need to run ldconfig and try accessing the command above

#ldconfig

Install Mod_Python

#cd mod_python-3.2.10
#./configure --with-apxs=/usr/local/apache2/bin/apxs \
--with-python=/usr/local/bin/python2.5 \
--with-flex=/usr/local/bin/flex
#make install_dso
#make install_py_lib

It will automatically install mod_python.so to /usr/local/apache2/modules

Configure Apache to Support Mod_Python

#vi /usr/local/apache2/conf/httpd.conf

####Add this lines below####

LoadModule python_module modules/mod_python.so

### Example Virtual Host ###
<VirtualHost 10.10.10.10>
    ServerName testing.com
    ServerAlias www.testing.com
    DocumentRoot "/home/domains/testing.com/htdocs"
    <Directory "/home/domains/testing.com/htdocs">
       
    <IfModule mod_python.c>
        AddHandler mod_python .py .psp
        PythonHandler mod_python.publisher | .py
        PythonHandler mod_python.psp | .psp
    </IfModule>
   
    Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Restart Apache Webserver

#/usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start

Create testing.py in /home/domains/testing.com/htdocs for publisher handler

#cd /home/domains/testing.com/htdocs
#vi testing.py
def index(req):
return "Test successful";

Create testing.psp /home/domains/testing.com/htdocs forPSP handler

#vi testing.psp
<html>
<body>
<h1><% req.write("Hello!") %></h1>
</body>
</html>

Try to access testing.py through browser
http://testing.com/testing.py and you will see a Test successfull print in the browser

Try to access testing.psp through browser
http://testing.com/testing.psp and you will see a BOLD/HEADER with Hello print in the browser

Note: mod_python seems to have a bug in few version so if there is a bug on the mod_python try to using CVS / SVN version.

NOTE:
I've successfully applied mod_python with apache2 in centos server. so i assume this will also working with your server with centos server.

if you have any problem with mod_python, try to install mod_python with SVN/CVS version.


Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Recent comments

Facebook Fans

Sponsors

Tag Cloud