I'm facing an issue with my Django Application Deployment. I have followed several tutorials ( lastly this one : https://www.youtube.com/watch?v=APCQ15YqqQ0) to help me deploy my application, I don't understand why my Handler is not working. Here is my web.config file :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\users\xxx\documents\github\app_folder\scripts\python.exe|c:\users\xxx\documents\github\app_folder\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="C:\Users\xxx\Documents\GitHub\app_folder\app" />
<add key="WSGI_HANDLER" value="app_name.wsgi.application" />
<add key="DJANGO_SETTINGS_MODULE" value="app_name.settings" />
</appSettings>
</configuration>
As I have my virtualenv in the app_folder
folder, app
folder contains the Django project.
I have this message for output :
Additional information about the error :
Module FastCgiModule
Notification ExecuteRequestHandler
Handler django_handler_test
Error code 0x8007010b
URL requested http://localhost:94/
Physical Path C:\Users\xxx\Documents\GitHub\app_folder\app
Session opening Method Anonyme
User Session Anonyme
I translated the category name as they were in french
Even if it may not be a good practice, I intend to deploy it on a Windows Computer for now before a complete deployment on a Server (Windows or Linux). For now, I really need to complete my test on a Windows environnement. Thanks you for your help and understanding.
First, make sure you are using the python version above 3.6.another need to not is you install the python for all users and set the installation folder under the drive e.g "C:\Python36"
Installing Django on Windows:
Django can be installed using PIP with a command such as pip install django
get the application folder from the user directory to c drive.
enable iis cgi feature:
install wfastcgi using below command:
pip install wfastcgi
Configuring IIS to run a FastCGI application:
1)select your site in iis.
2)open Handler mappings configuration feature.
3)In it, click on the Add Module Mapping… action, and enter the following information:
<system.webServer>
<handlers>
<add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
scriptProcessor="C:\Python37-32\python.exe|C:\Python37-32\Lib\site-packages\wfastcgi.py"
resourceType="Unspecified" requireAccess="Script"/>
</handlers>
</system.webServer>
4)Next, click the Request restrictions button and edit the Mapping tab. Uncheck the “Invoke handler only if the request is mapped to…” checkbox (otherwise, IIS will have problems mapping what it thinks are subdirectories in the URL request):
Click OK on the handler information dialog. IIS will then ask you to confirm the creation of a matching FastCGI application entry which you will need to confirm.
Configure FastCGI in IIS:
1)open iis and double-click the “FastCGI Settings” icon
2)select your python executable and add the below environment variable:
Name: PYTHONPATH Value: C:appsfoo
Name: WSGI_HANDLER Value: django.core.wsgi.get_wsgi_application()
Name: DJANGO_SETTINGS_MODULE Value: django_iis_example.settings
Note: do not forget to assign the iis_iusrs and iusr permission to the python and site folder.
https://docs.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019
User contributions licensed under CC BY-SA 3.0