IIS部署Django时,500 错误解决办法
一、IIS下部署Django
2020.09.02 22:54:14字数 129阅读 42
IIS下部署Django
- 
安装Django:
pip install Django
pip install wfastcgi
- 
IIS配置文件
Django项目根目录下建立web.config文件,内容如下
<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers>
                <add name="Python FastCGI"
                     path="*"
                     verb="*"
                     modules="FastCgiModule"
                     scriptProcessor="python.exe完整路径|fastcgi.py完整路径"
                     resourceType="Unspecified"
                     requireAccess="Script"/>
            </handlers>
        </system.webServer>
        <appSettings>
            <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
            <add key="PYTHONPATH" value="django项目路径" />
            <add key="DJANGO_SETTINGS_MODULE" value="项目名称.settings" />
        </appSettings>
    </configuration>
- 
静态文件配置:
在静态文件所在文件夹内建立web.config文件,内容如下
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <!-- this configuration overrides the FastCGI handler to let IIS serve the static files -->
    <handlers>
    <clear/>
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
    </handlers>
  </system.webServer>
</configuration>
- 
500 错误解决办法
点击IIS管理器左边的“应用程序池”,再点击右边的“设置应用程序池默认设置...",找到“进程模型”下的“标识”选项,改为 LocalSystem
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号