1. 安装apache
1)安装arp
tar -zxf apr-1.5.0.tar.gz #解压压缩包 压缩包名称根据版本号决定
cd apr-1.5.0 #进入解压目录
./configure --prefix=/usr/local/apr #进行安装配置 设置安装位置
make #编译
make install #安装
2) 安装 apr-util
tar –zxvf apr-util-1.5.3.tar.gz #解压 压缩包名称根据版本号决定
cd apr-util-1.5.3 #进入解压目录
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
3) 安装pcre
unzip –o pcre-8.34.zip #解压 文件名依据版本号而定
cd pcre-8.34
./configure --prefix=/usr/local/pcre
make
make install
4) 安装apache
tar –zxvf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make
make install
验证安装结果
1)启动apache
cd /usr/local/apache2/bin
apachectl –k start
或者
service apache2 start
如果成功,会看到如下画面
2) 如何控制apache
service apache2 start
或者
apachectl start
相关 start/stop/restart
2. 安装python 2.7
3. 安装django 1.6.5
4. 安装mod_wsgi
说明: mod_wsgi 是apache调用python的连接组件,编辑时切记要关联使用apache的apxs 和 指定版本目录下的 python 路径
tar –zxvf mod_wsgi-3.4.tar.gz
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python
make
make install
ps:make错误: src/server/wsgi_python.h:24:20: fatal error: Python.h: No such file or directory
$ yum search python | grep python-devel
$ sudo yum install python-devel.x86_64
其中/usr/local/apache2为Apache的安装目录,确保apxs存在于bin目录中,/usr/bin/python为Ubuntu中python默认安装位置。
接下来执行make 命令,进行编译;
如果到这里都顺利的话,会提示“chmod 755 /usr/local/apache2/modules/mod_wsgi.so” 为mod_wsgi.so赋权
chmod 755 /usr/local/apache2/modules/mod_wsgi.so
5. 安装setuptools
说明: 安装了setuptools 才能安装mysql_python
python setup.py build
python setup.py install
Installed /usr/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg
6. 安装mysql数据库
http://blog.csdn.net/shulianghan/article/details/17309411
7. 安装MySQL support for python
$ tar xfz MySQL-python-1.2.1.tar.gz
$ cd MySQL-python-1.2.1
$ # edit site.cfg if necessary
mysql_config = /usr/local/mysql5/bin/mysql_config
$ python setup.py build
$ sudo python setup.py install # or su first
Installed /usr/local/lib/python2.6/site-packages/MySQL_python-1.2.3-py2.6-linux-i686.egg
验证是否安装成功
vi /etc/ld.so.conf
在最后一行添加库文件所在的目录路径/usr/local/mysql/lib/mysql/然后保存 --此处是mysql安装的路径
执行ldconfig
再执行ldconfig -v | grep libmysqlclient* 应该可以看到MySQL动态连接库文件名
8. 使用django工程联调
Q&A
1. libpython2.7.so.1.0 cannot open 解决方法
http://blog.csdn.net/huzhenwei/article/details/7339548
2. apache 启动时出现 httpd: apr_sockaddr_info_get() failed for 报错
执行apachectl start时候,提示如下错误:
原因:这个问题应该是没有在 /etc/httpd/conf/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。
解决办法:
(1)可以设定httpd.conf文件中的 ServerName,如下:ServerName localhost:80
(2)在 /etc/hosts 中填入自己的主机名称 bogon,如下:127.0.0.1 shiwei (用户名称)
3. service httpd does not support chkconfig
apache 作为linux启动就运行服务程序
#chkconfig: 2345 10 90
#description: Activates/Deactivates Apache Web Server加上上面这两行就可以,#必须有
其中:2345是设为要启动的运行级别,10是启动优先级,90是杀死进程的优先级,谁优先谁先挂的意思
4.python 安装 -fPIC问题
http://taoo.iteye.com/blog/1826912
5.确认python当前关联的site-package位置
rom distutils.sysconfig import get_python_lib print get_python_lib()
参考文章
http://www.cnblogs.com/fengzheng/p/3619406.html