Here is a simple way tutorial to install Python with mod_wsgi in CentOS 5.6 cPanel.
First we need to know what is mod_wsgi. It is an Apache module that can host any Python application and support the Python WSGI interface. This module also suitable to use in high hosting performance website.
Python is a programming language that work more quickly and integrate systems more effectively with a lower maintenance costs.
first of all Create Python directory with
#mkdir /usr/src/python2.7 #cd /usr/src/python2.7
After that install SQLite through these commands
#cd /root #wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz #tar zxvf sqlite-autoconf-3070701.tar.gz #cd sqlite-autoconf-3070701 #./configure #make && make install
Then Install Python 2.7 through this don’t install it through repository, as repository provides old version.
#cd /usr/src/python2.7 #wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgz #tar zxvf Python-2.7.2.tgz #cd Python-2.7.2 #./configure --prefix=/opt/python2.7 --with-threads --enable-shared #make && make install
Now Create a symbolic link to alternate Python 2.7
#ln -s /opt/python2.7/bin/python /usr/bin/python2.7 #echo '/opt/python2.7/lib'>> /etc/ld.so.conf.d/opt-python2.7.conf #ldconfig
Python New Version is verified through this command.
#/usr/bin/python2.7
The result will be as shown below :
Python 2.7.2 (default, Sep 3 2011, 18:28:42)[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
Press control + D to exit from here.
Next step is installation of Python setup-tools. Which is achieved though these commands.
#cd /usr/src/python2.7 #wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg #sh setuptools-0.6c11-py2.7.egg --prefix=/opt/python2.7
Install Virtualenv to Python 2.7
#cd /opt/python2.7/bin #./easy_install virtualenv
Install mod_wsgi
#cd /opt/python2.7/lib/python2.7/config/ #ln -s ../../libpython2.7.so #cd /usr/src/python2.7/ #wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz #tar zxvf mod_wsgi-3.3.tar.gz #cd mod_wsgi-3.3 #./configure --with-python=/opt/python2.7/bin/python #make && make install
Next we need to avoid cPanel easy_apache to clear up /usr/local/apache/modules folder
#mkdir /usr/local/apache/extramodules #mv /usr/local/apache/modules/mod_wsgi.so /usr/local/apache/extramodules/
Added mod_wsgi configrations in Apache configuration file.
#nano /usr/local/apache/conf/includes/pre_virtualhost_global.conf
Insert two line shown below:
LoadModule wsgi_module /usr/local/apache/extramodules/mod_wsgi.so AddHandler wsgi-script .wsgi
Apache Services is restart though following command.
#/scripts/restartsrv httpd
Done now your cPanel already work with python 2.7 and mod_wsgi
Python script script testing method is elaborated bellow.
#cd /home/testing/htdocs/ [Change it to your Website VHOST path]
#nano test.wsgi
def application(environ, start_response):
"""Simplest possible application object"""
output = "Hello World"
status = '200 OK'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]

#1 by Ashleigh on December 31, 2011 - 12:53 am
Quote
Stumbled on your web blog through Reddit. You already know I am signing up to your rss.
#2 by 1099 form on January 6, 2012 - 11:45 pm
Quote
whats your facebook profile?