使用iis7部署django项目
一、首先安装wfastcgi
使用命令 pip install wfastcgi 即可安装
然后再运行一下 wfastcgi-enable 命令启用它即可,成功运行后,会输出一个目录,这个目录需要被加到配置文件
二、配置 web.config
在manager.py的同级目录新建一个web.config文件,官方模板如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="<Path to Python>\python.exe|<Path to Python>\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script"/>
</handlers>
</system.webServer>
<appSettings>
<add key="WSGI_HANDLER" value="<WSGI_HANDLER based on Django Version>" />
<add key="PYTHONPATH" value="<Path to Django App>" />
<add key="DJANGO_SETTINGS_MODULE" value="<Django App>.settings" />
</appSettings>
</configuration>
静态文件
在你的静态文件夹下新建web.config,配置如下
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <remove name="Python FastCGI" /> </handlers> </system.webServer> </configuration>
剩下来的就是使用IIS新建站点了。
详细信息请参考如下链接
https://blog.csdn.net/gzlaiyonghao/article/details/70243639
http://kronoskoders.logdown.com/posts/1074588-running-a-django-app-on-windows-iis
机器能干的事,就不要让人去做了

浙公网安备 33010602011771号