您的位置:首页 > 运维架构 > Apache

CentOS7下apache2部署django应用

2017-07-08 00:00 417 查看
一、下载安装包

1) pcre https://sourceforge.net/projects/pcre/?source=typ_redirect
2) httpd https://archive.apache.org/dist/httpd/httpd-2.4.9.tar.gz
3) apr http://mirrors.hust.edu.cn/apache//apr/apr-1.6.2.tar.gz
4) apr-util http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.0.tar.gz
二、解压编译安装

1)安装关联文件

这时候第一步下载的文件就用的上了;
安装顺序apr -> apr-util ,当然pcre可以乱入(顺序不重要);
安装过程,配置 -> 编译 -> 安装 三部曲;

主要说配置:
进入解压后的apr文件包:
[root@root]# ./configure --prefix=/usr/local/apr/(这里配置的是安装路径)
# make
# make intall
进入解压后的apr-util文件包:
[root@root]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config(配置apr-util安装路径,并关联apr文件——确保路径正确)
# make
# make intall
进入解压后的pcre文件包:
[root@root]# ./configure --prefix=/usr/local/pcre(配置安装路径)
# make
# make intall

2)安装httpd

进入解压后的httpd文件包:
[root@root]# ./configure --prefix=/usr/local/apache/ \
--sysconfdir=/etc/httpd \ //指定Apache服务器的配置文件存放位置
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre/  \
--enable-so \ //以动态共享对象(DSO)编译---记得要加,否则以后手动修改配置文件加载新的模块,比如,不配置的话,安装好PHP后,要手动修改conf来loadmodule……
--enable-deflate=shared \ //缩小传输编码的支持
--enable-expires=shared \ //期满头控制
--enable-rewrite=shared \ //基于规则的URL操控
--enable-static-support //建立一个静态链接版本的支持
# make
# make intall

3)启动

进入Apache的安装目录/usr/local/apache/bin(如果你没自定义的话):

./apachectl start  #启动服务
./apachectl stop   #关闭服务
./apachectl restart  #重启服务

三、源码安装mod_wsgi

1)下载源码 https://github.com/GrahamDumpleton/wsgiorg.git
2)到项目目录:

./configure --with-python=/usr/bin/python --with-apxs=/usr/local/apache/bin/apxs
make
make install

3)配置httpd.conf

a)/etc/httpd/httpd.conf 增加:LoadModule wsgi_module modules/mod_wsgi.so

b)参数django部署wsgi应用,参考地址:https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/

c)重启httpd服务 /usr/local/apache/bin/apachectl restart
http://localhost,可查看效果
部分代码参考:https://segmentfault.com/a/1190000004236397?_ea=539001
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: