1.安装wfastcgi

在Windows下,我们没法使用uwsgi,但我们可以使用wfastcgi替代它,打开CMD窗口,输入命令安装wfastcgi

pip install wfastcgi

2.安装成功之后,通过下面命令启动它:

wfastcgi-enable

 3.在项目根目录里新建一个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="django.core.wsgi.get_wsgi_application()" />

            <add key="PYTHONPATH" value="<Path to Django App>" />

            <add key="DJANGO_SETTINGS_MODULE" value="<Django App>.settings" />

        </appSettings>

    </configuration>

4.收集静态文件

python manage.py collectstatic

5.在根目录下创建static中新建一个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>

5.配置windows防火墙的入站规则,把端口写入规则允许访问

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐