1.安装基本依懒的包
- yum install gcc gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel
复制代码
2.安装python2.6.4
- wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tgz
- tar xvfz Python-2.6.4.tgz
- cd Python-2.6.4
- ./configure --prefix=/usr/local/python2.6 --with-threads --enable-shared
- make && make install
复制代码
添加alias
- vi ~/.bash_profile
- alias python='/usr/local/python2.6/bin/python'
- source ~/.bash_profile
复制代码
建立软链接
- ln -s /opt/python2.6/bin/python /usr/bin/python2.6
复制代码
配置ld相关共享库文件: vi /etc/ld.so.conf.d/python2.6.conf
- /usr/local/python2.6/lib/
复制代码 保存后执行: ldconfig
3.安装setuptools
- wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
- tar zxvf setuptools-0.6c11.tar.gz
- cd setuptools-0.6c11
- python setup.py install
复制代码
4.安装python-mysql(注意先安装上mysql-devel相关的包)
- wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
- tar xvfz MySQL-python-1.2.2.tar.gz
- cd MySQL-python-1.2.2
- python setup.py build
- python setup.py install
复制代码
执行python >>> import MySQLdb //如果无报错,表明安装成功。 >>>
5.安装配置mod_wsgi
- cd /usr/local/python2.6/lib/python2.6/config
- ln -s ../../libpython2.6.so .
复制代码
- wget http://modwsgi.googlecode.com/files/mod_wsgi-3.2.tar.gz
- cd mod_wsgi-3.2
- ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/local/python2.6/bin/python
- make && make install
复制代码
安装成功自动向apache添加mod_wsgi模块。
- ls -Al /usr/local/apache2/modules/mod_wsgi.so
复制代码 重启apache后查看看模块是否正常加载:
- /usr/local/apache2/bin/httpd -M
复制代码
6.安装web.py
- wget http://webpy.org/static/web.py-0.33.tar.gz
- cd web.py-0.33
- python setup.py installl
复制代码
7.配置apache虚拟主机,测试web.py相关程序. # cat py.linuxtone.org.conf
- <VirtualHost *:80>
- ServerAdmin system@linuxtone.org
- DocumentRoot /data/www/wwwroot/webpy-app
- ServerName py.linuxtone.org
- AddDefaultCharset UTF-8
- ErrorLog /data/logs/py.linuxtone.org-error_log
- WSGIScriptAlias /linuxtone /data/www/wwwroot/webpy-app/linuxtone.py/
- Alias /lt/static /data/www/wwwroot/webpy-app/static/
- AddType text/html .py
- <Directory /data/www/wwwroot/webpy-app/>
- Order deny,allow
- Allow from all
- </Directory>
- </VirtualHost>
复制代码
# vi /data/www/wwwroot/webpy-app/linuxtone.py
- #!/usr/bin/env python
- import web
- urls = (
- '/.*', 'hello',
- )
- class hello:
- def GET(self):
- return "Hello, linuxtone."
- application = web.application(urls, globals()).wsgifunc()
复制代码
|