Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying two different Django Applications on Windows Server in IIS

Tags:

iis

django

I am deploying two different Django applications on Windows 2012 in IIS. My first application is running but I can't seem to run my second application.

My question is how do I configure my FastCGI Settings if I have two PYTHONPATH and two DJANGO_SETTINGS_MODULE?

Do I put a semicolon every after values? For example:

NAME: DJANGO_SETTINGS_MODULE

VALUE: mysettings.settings;myothersettings.settings

NAME: PYTHONPATH

VALUE: C:\PythonApps\firstapp;C:\PythonApps\secondapp

like image 443
Eak321 Avatar asked Sep 14 '25 01:09

Eak321


1 Answers

Step 1) Web Server's FastCGI Settings - in your web server under FastCGI Settings create an application for each site you will be running. If you are using a venv be sure to point to your python.exe and wfastcgi.py file within that venv. For isntance, I have one that points to:

"C:\Apps\.virtualenv\[enviroment-name]\python.exe|C:\Apps\.virtualenv\[enviroment-name]\Lib\site-packages\wfastcgi.py" 

And one that points to:

"C:\Python37\pytohn.exe|C:\Python37\Lib\site-packages\wfastcgi.py"

Step 2) Website's Handler Mappings - for each handler mapping, The Module with be FastCgiModule and the settings should mirror the application settings you created in step one. So one site should have an executable of:

"C:\Apps\.virtualenv\[enviroment-name]\python.exe|C:\Apps\.virtualenv\[enviroment-name]\Lib\site-packages\wfastcgi.py" 

The other should be:

"C:\Python37\pytohn.exe|C:\Python37\Lib\site-packages\wfastcgi.py"

Step 3) Web.Config File - In the root of your django app, save a file like the one below. The web server handler should coincide with the application setting you are using. Down in application settings you can define your WSGI_HANDLER, PYTHONPATH, and DJANGO_SETTINGS_MODULE.
https://pypi.org/project/wfastcgi/

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="Python FastCGI"
           path="*"
           verb="*"
           modules="FastCgiModule"
           scriptProcessor="C:\python37\python.exe|C:\python37\Lib\site-packages\wfastcgi.py"
           resourceType="Unspecified"
           requireAccess="Script" />
    </handlers>
  </system.webServer>

  <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="core.wsgi.application" />
    <add key="PYTHONPATH" value="C:\apps\django\dash" />

    <!-- Optional settings -->
    <add key="DJANGO_SETTINGS_MODULE" value="core.settings.production" />
  </appSettings>
</configuration>
like image 60
Nate Hawk Avatar answered Sep 16 '25 16:09

Nate Hawk