废话不多说,干货直接上。
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混用。