windows server 部署Django,Apache方式

http://blog.csdn.net/mandmg/article/details/60963721

静态文件的问题:

https://docs.djangoproject.com/en/1.11/howto/static-files/deployment/

https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/modwsgi/#serving-files

http://jingyan.baidu.com/article/db55b609a93b114ba30a2ffb.html

https://www.oschina.net/question/2517356_2141213

安装环境:windows server 2008 R2 64bit,

使用python python-3.6.1-amd64,下载地址,Apache HTTP server2.4_X64,下载地址

,mod_wsgi下载地址,选择mod_wsgi‑4.5.15+ap24vc14‑cp36‑cp36m‑win_amd64.whl,

常规安装好apache,python,pip install django之后,

在。whl文件的目录中,pip install mod_wsgi-4.5....whl,

运行命令mod_wsgi-express module-config,在我的环境中,出现

LoadFile "c:/python/python36.dll"

LoadModule wsgi_module "c:/python/lib/site-packages/mod_wsgi/server/mod_wsgi.cp3

6-win_amd64.pyd"

WSGIPythonHome "c:/python"

,这些在Apache配置文件中会用到。

我将Django工程文件放在C:\pythonweb文件夹下.

在Apache2.4/conf/httpd.conf 文件中,在LoadModule下面添加

LoadFile "c:/python/python36.dll"

LoadModule wsgi_module "c:/python/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"

最好手敲。

然后添加

ServerName 你的IP:80

WSGIPythonHome "C:\python"

WSGIScriptAlias / C:\pythonweb\mysite\mysite\wsgi.py

WSGIPythonPath C:\pythonweb\mysite

<Directory C:\pythonweb\mysite>

<Files wsgi.py>

Require all granted

</Files>

</Directory>

重启httpd 即可。如果出现Requested Operation Failed,可能是conf文件配置的问题,在bin文件夹中,cmd方式输入httpd -k start

看看错误信息。

/admin站点前端显示不正常的问题。

相关的js css文件没有加载。解决如下:

1.在settings.py文件中添加

STATIC_ROOT='C:\pythonweb\mysite\static'

2.执行命令python manage.py collectstatic,此时,相关静态文件就会复制到STATIC_ROOT中

3.在httpd.conf 文件中添加

Alias /static C:\pythonweb\mysite\static

<Directory C:\pythonweb\mysite\static>

Require all granted

</Directory>

重启httpd。