Move to the target directory and execute the following
python -m venv venv
First, enable venv
venv\Scripts\activate.bat
If you want to use Django with IIS, you need wfastcgi, so install it as well.
(venv)> pip install django
(venv)> pip install wfastcgi
(venv)> venv\Scripts\wfastcgi-enable.exe
OK if it comes out as follows
Configure configuration changes Commit path"MACHINE/WEBROOT/APPHOST"of"MACHINE/WEBROOT/APPHOST"Section"system.webServer/fastCgi"Applied to
"d:\webroot\venv\scripts\python.exe|d:\webroot\venv\lib\site-packages\wfastcgi.py" can now be used as a FastCGI script processor
The output will be used later.
d:\webroot\venv\scripts\python.exe|d:\webroot\venv\lib\site-packages\wfastcgi.py
# Unlock system.webServer / handlers
(venv)> %windir%\system32\inetsrv\appcmd unlock config -section:system.webServer/handlers
 OK if it comes out as follows
Configuration path"MACHINE/WEBROOT/APPHOST"Section"system.webServer/handlers"Unlocked.
# Allows Python files to be executed with handler mapping.
 Set as follows in [Site]-> [Handler Mapping]
 scriptProcessor should use the result obtained by ``` wfastcgi-enable.exe```. 
# Creating web.config
 Create the following file and place it in the Django root directory.
#### **`web.config`**
```xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appSettings>
        <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
        <add key="PYTHONPATH" value="D:\webroot" />
        <add key="DJANGO_SETTINGS_MODULE" value="app.settings" />
    </appSettings>
    <system.webServer>
        <handlers>
            <add name="Python FastCGI"
                 path="*"
                 verb="*"
                 modules="FastCgiModule"
                 scriptProcessor="d:\webroot\venv\scripts\python.exe|d:\webroot\venv\lib\site-packages\wfastcgi.py"
                 resourceType="Unspecified" />
        </handlers>
    </system.webServer>
</configuration>
You are now ready.
Recommended Posts