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

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐