How To Install Python 2.7 with mod_wsgi on CentOS 5.6 with cPanel
2012-02-23 22:50
609 查看
How To Install Python 2.7 with mod_wsgi on CentOS 5.6 with cPanel - Software Documentation Kit
Prerequisites:
CentOS 5.6 32 or 64 bit with root access
cPanel
Note: we are not using cPanel custom modules guide because it only works with built-in Python 2.4.Creating Python folder
Now we need to install Python setup-tools
You can create a test.wsgi file to test Python scripts
How To Install Python 2.7 with mod_wsgi on CentOS 5.6 with cPanel
09.04.2011, Linux, Programming, Tutorial, by polk.This is a step by step tutorial which will help you install Python 2.7 with mod_wsgi onto CentOS 5.6 and cPanel.Prerequisites:
CentOS 5.6 32 or 64 bit with root access
cPanel
Note: we are not using cPanel custom modules guide because it only works with built-in Python 2.4.Creating Python folder
mkdir /usr/src/python2.7 cd /usr/src/python2.7If required by your project, you can install SQLite
wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz tar zxvf sqlite-autoconf-3070701.tar.gz cd sqlite-autoconf-3070701 ./configure make make installInstalling Python 2.7 into alternate location since we don’t want to break Centos 5.6 (yum) that uses Python 2.4
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 installCreating symbolic link to the alternate Python version
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 ldconfigLet’s test if new Python version works
/usr/bin/python2.7If successful you will see something like this:
Python 2.7.2 (default, Sep 3 2011, 18:28:42)[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2press control+D to exit
Now we need to install Python setup-tools
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.7Installing virtualenv to our Python 2.7
cd /opt/python2.7/bin/ ./easy_install virtualenvInstalling mod_wsgi (this module will work only with python 2.7)
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 installWe need to avoid cPanel’s easy_apache clearing up /usr/local/apache/modules folder
mkdir /usr/local/apache/extramodules mv /usr/local/apache/modules/mod_wsgi.so /usr/local/apache/extramodules/Include mod_wsgi into Apache configuration
nano /usr/local/apache/conf/includes/pre_virtualhost_global.confpaste:
LoadModule wsgi_module /usr/local/apache/extramodules/mod_wsgi.so AddHandler wsgi-script .wsgiBefore we restart Apache, lets test if we have the correct configuration
service httpd configtestYou should get this answer:
Syntax OKNow restart Apache
/scripts/restartsrv httpdPython 2.7 with mod_wsgi is now installed on your cPanel server.
You can create a test.wsgi file to test Python scripts
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]Please post your questions and comments below.
相关文章推荐
- How to Install Python 2.7 on CentOS6.5
- How to install Python 2.7 and Python 3.3 on CentOS 6
- How to install Python 2.7 and Python 3.3 on CentOS 6
- Howto Install PHP 5.4, 5.5 or 5.6 on CentOS 6 and CentOS 7
- How to Install LAMP (Apache 2.4, MySQL 5.6, and PHP 5.4) on CentOS/RHEL 7
- How to install Python 2.7.3 on CentOS 6.2
- How to install Python 2.7.3 on CentOS 6.2
- How to Install MySQL 5.6 on CentOS 6.3/RedHat EL6/Fedora
- How to install MySQL Server 5.6 on CentOS 7 / RHEL 7
- How to Install MySQL 5.6 on CentOS 6.3/RedHat EL6/Fedora
- How to install python, wxPython and ride on CENTOS
- How To Install Nginx on CentOS 7(转)
- How To Install / Configure VNC Server On CentOS 7.0
- centos howto yum install mysql-python
- how to install ntopng on centos
- How to Install and Configure Nginx from Source on centos--转
- CentOS7: How to install Desktop Environments on CentOS 7?
- How to install Mediaproxy 2.5.2 on CentOS 6 64 bit
- How to Install RSyslog+MySQL with LogAnalyzer on CentOS
- How to Install Apache OpenOffice on RHEL/CentOS