0

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.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
aliitaqk
  • 65
  • 1
  • 8
  • Is your issue solved? If your issue is solved then I request you to mark the helpful suggestion as an answer. This will help other people who face the same issue. If your issue still exists then try to refer the solution given by the community members. If then also you have any further questions then let us know about it. We will try to provide further suggestions to solve the issue. Thanks for your understanding. – Jalpa Panchal Oct 28 '20 at 09:37
  • I wasn't notified for the answer... I will test it as soon as I get home ! – aliitaqk Dec 21 '20 at 11:33

1 Answers1

0

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"

enter image description here

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:

enter image description here

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):

enter image description here

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://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2019

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
  • Hello, thank you for your help. Actually, my main issue is that I wanted to export my virtualenv at the same time but it was definetly not the best thing to do. Also, I didn't need to edit FastCGI as the website is already recognize my web.config. I recommand to anyone who struggle like me to forget the virtualenv and to see the tutorial in my main question :) – aliitaqk Dec 27 '20 at 19:16