-
Open a Powershell terminal in Admin mode
-
Browse to c:\inetweb\wwwroot
-
Delete the IIS start files in the c:\inetweb\wwwroot\ directory
-
Checkout the code from the repo:
git clone https://github.com/ryancheley/gcp-django-demo mywebsite
-
Open VS Code as Admin
-
Open Folder c:\inetweb\wwwroot\mywebsite
-
Trust the Code if given the prompt
-
Open terminal
-
Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
.\venv\Scripts\activate
- Install the requirements from the requirements.txt file:
pip install -r requirements.txt
- Run
wfastcgi-enable
command:
wfastcgi-enable
- Update
web.config
to put in needed values (e.g. server name, path to python executable, and path to the Django application):
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\inetweb\wwwroot\mywebsite\venv\Scripts\python.exe|C:\inetweb\wwwroot\mywebsite\venv\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<httpErrors errorMode="Detailed" />
<directoryBrowse enabled="false" />
<httpProtocol>
<customHeaders>
<add name="X-Powered-By" value="Django/3.2.2" />
</customHeaders>
</httpProtocol>
<staticContent>
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
</system.webServer>
</configuration>
- Run
migrate
command:
python manage.py migrate
- Run development server:
python manage.py runserver
-
Verify that the site works by opening a web browser and navigating to
http://localhost:8000/
. -
Stop the development server
-
Collect static files:
python manage.py collectstatic
-
Grant Full Permissions for web directory to IIS AppPool\DefaultAppPool
-
Go to IIS Manager
-
Add Virtual Directory to Static Folder
-
Unlock the configuration manager
-
Move
web.config
to parent directory c:\inetweb\wwwroot\ -
Restart the WebSite
That's it! Your Django application should now be deployed and running on IIS.