Winserver+Apache+django部署

庫庫的碼農發表於2018-04-03

廢話不多說,乾貨直接上。

winserver2012 + django2.0.1 + apache 部署過程

1 ,python ==> 3.4 64位 https://www.python.org/downloads/release/python-353/

2 ,django ==> 2.0.1 64位

3 ,apache ==> 2.2.4 64位 https://www.apachehaus.com/cgi-bin/download.plx

mod_wsgi

1 , pip install mod_wsgi and http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

安裝微軟SDK7.1 or vs2010-2018 pip install mod_wsgi需要依賴編譯

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi 下載:mod_wsgi‑4.5.24+ap24vc10‑cp34‑cp34m‑win_amd64.whl

以上環境安裝完成之後,mod_wsgi.whl檔案下載完成之後,放在C盤根目錄下,

開啟終端,進入C盤根目錄,

1, pip install “mod_wsgi‑4.5.24+ap24vc10‑cp34‑cp34m‑win_amd64.whl”

pip完成之後,緊接著輸入: mod_wsgi-express module-config

輸出結果:
    1: LoadFile “c:/users/administrator/appdata/local/programs/python/python35/python35.dll”

    2: LoadModule wsgi_module “c:/users/administrator/envs/mode_env/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd”

    3: WSGIPythonHome “c:/python34”

之後配置apache

進入apache目錄==>bin修改httpd.conf檔案

 

1: Define SRVROOT “C:/pyobj/apache24/apache24”

 

2: 設定監聽得埠號前提埠必須開放 80
Listen 0.0.0.0:80

 

3:設定伺服器地址
ServerName ***.***.***.***:80

 

4:在最底部新增如下配置

LoadModule wsgi_module “c:/users/administrator/envs/mode_env/lib/site-packages/mod_wsgi/server/mod_wsgi.cp35-win_amd64.pyd”

WSGIPythonHome “c:/users/administrator/envs/mode_env” == >python地址

# django專案中得wsgi.py 路徑 (絕對路徑)

WSGIScriptAlias / C:/pyobj/Apachedemo/Apachedemo/wsgi.py

# django專案路徑

WSGIPythonPath C:/pyobj/Apachedemo

# 配置wsgi許可權
<Directory C:/pyobj/Apachedemo/Apachedemo>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

 

配置完成之後開啟終端進入apache/bin目錄

 

將apache新增為系統服務

httpd -k install

# 啟動服務
httpd -k start

# 停止
httpd -k stop

# 重啟
httpd -k restart

安裝過程中,如果機器是64位,以上安裝包全部都得是64為,不可以64/32混用。


相關文章