CentOS7下apache2部署django应用


1、下载安装包python

1) pcre https://sourceforge.net/projects/pcre/?source=typ_redirectgit

2) httpd https://archive.apache.org/dist/httpd/httpd-2.4.9.tar.gzgithub

3) apr http://mirrors.hust.edu.cn/apache//apr/apr-1.6.2.tar.gzapache

4) apr-util http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.0.tar.gzdjango

 

2、解压编译安装segmentfault

1)安装关联文件bash

这时候第一步下载的文件就用的上了;
安装顺序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(若是你没自定义的话):.net

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

3、源码安装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

相关文章
相关标签/搜索