1. Install Apache:
Yum install-y httpd Httpd-devel
Modify the configuration of servername in/etc/httpd/conf/httpd.conf so that http://*:*/can access normally
2. Install Python:
wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz
TAR-XZVF python-2.7.8.tgz
CD Python-2.7.8
./configure--enable-shared=enable
Make && make install
3. Fix Yum:
Yum found an error because centos6.5 's python default version is 2.6.*, and Yum is Python-based.
Solution:
Cp/usr/bin/python/usr/bin/python_bak
Rm-f/usr/bin/python
Ln-s/usr/local/bin/python2.7/usr/bin/python
Vi/usr/bin/yum change/usr/bin/python to:/usr/bin/python2.6
4. Install Mod_wsgi:
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/3.5.tar.gz
TAR-XZVF 3.5.gz
CD mod_wsgi-3.5
./configure--with-apxs=/usr/sbin/apxs--with-python=/usr/local/bin/python2.7 #注意这里apxs, Python path is determined by Whereis
Ld_run_path=/usr/local/lib make #注意LD_RUN_PATH =/usr/local/lib to set the environment variable to get the location of the libpython.so. If not, when you turn on Apache, you will be prompted not to find libpython2.7.so.1.0
Make install
5. Apache Loading WSGI:
Vi/etc/httpd/conf/httpd.conf
Add after a bunch of module loads: LoadModule wsgi_module modules/mod_wsgi.so
6. Install web.py:
Http://webpy.org/static/web.py-0.37.tar.gz
Python setup.py Install
7. Deploy the Python-based Web program developed by the WEB.PY framework:
Add in httpd.conf:
wsgiscriptalias/smushit/var/www/smushit/code.py/
alias/smushit/static/var/www/smushit/static/
AddType text/html. py
<Directory/var/www/smushit/>
Order Deny,allow
Allow from all
</Directory>
Where Smushit is the directory of the Web system.
The code for code.py is:
Import Web
URLs = ('/.* ', ' Code ')
Class Code:
def GET (self):
Return "Hello, world."
application = web.application (URLs, Globals ()). Wsgifunc ()
Test found: http://192.168.178.147/smushit/access is normal, that is, configuration OK.
Reference: Http://webpy.org/cookbook/mod_wsgi-apache
This article is from the "Inner Peace, Fire Rebirth" blog, please be sure to keep this source http://itisforyou.blog.51cto.com/9778869/1597024
Configuring Python + web.py + Apache deployment environment in CentOS6.5 environment