centos 源码编译安装httpd mod_wsgi 配置django

版本信息:centos7.1  python2.7.5  httpd2.2.31 mod_wsgi3.5(4.4没有成功,3.5可以成功)

1.关闭防火墙(centos7特有的命令,否则无法访问端口,当然你可以手动开放,我这里是图方便)

systemctl stop firewalld.service

2.卸载yum remove httpd httpd-devel (如果系统已经默认安装了httpd)

  rm -rf /etc/httpd  #删除httpd配置目录,防止后面的配置混淆

3. 去官网下载 httpd-2.2.31.tar.gz---源码编译安装相当于安装了对应的devel包

tar -xvf httpd-2.2.31.tar.gz

cd httpd-2.2.31

./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so
--prefix=/usr/local/httpd :这个是指定我们安装的路径
--sysconfdir=/etc/httpd :这个是指定的配置文件路径
--enable-so :这个是指允许模块化使用
这样我们回车就开始了,程序比较大,可能时间比较长,耐心等待吧.....

编译完之后我们开始执行make命令了,这个也比较久,等吧......

make完了就开始执行make install真正开始执行安装了;

4.安装mod_wsgi (如果之前编译安装了python,那么安装python的时候需要带上  cd Python-2.7  ;    ./configure  --enable-shared --prefix=/usr/local/python2.7,否则mod_wsgi会出问题 

安装之前需要寻找apxs,这个在httpd源码编译安装已经安装了

find / -name apxs

发现目录 /usr/local/httpd/bin/apxs ,这里的目的是根据那个httpd去编译mod_wsgi,对应起来

cd mod_wsgi-3.5

./configure --with-python=/usr/local/bin/python2.7 --with-apxs=/usr/local/httpd/bin/apxs --enable-share 

make

make install

5.启动httpd

cd /usr/local/httpd/bin
./apachectl start
或者
./httpd -f /etc/httpd/httpd.conf -k restart  #这里必须手动带上配置,否则会出问题

5.当django页面出来

500 的时候,就基本好了,一是看wsgi.py是否正确,二是看debug=True,看页面报的错


分享到: 微信 更多