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

相關文章
相關標籤/搜索