linux+apache+django+mysql 部署

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启动就运行服务程序

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
但是在执行:
chkconfig --add httpd
        chkconfig httpd on
的时候出现错误:service httpd does not support chkconfig
解决办法:
打开 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)

#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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值