Coder Social home page Coder Social logo

gcp-django-demo's Introduction

Guide to Deploy Django on IIS using wfastcgi

  1. Open a Powershell terminal in Admin mode

  2. Browse to c:\inetweb\wwwroot

  3. Delete the IIS start files in the c:\inetweb\wwwroot\ directory

  4. Checkout the code from the repo:

git clone https://github.com/ryancheley/gcp-django-demo mywebsite
  1. Open VS Code as Admin

  2. Open Folder c:\inetweb\wwwroot\mywebsite

  3. Trust the Code if given the prompt

  4. Open terminal

  5. Create a virtual environment:

python -m venv venv
  1. Activate the virtual environment:
.\venv\Scripts\activate
  1. Install the requirements from the requirements.txt file:
pip install -r requirements.txt
  1. Run wfastcgi-enable command:
wfastcgi-enable
  1. 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>
  1. Run migrate command:
python manage.py migrate
  1. Run development server:
python manage.py runserver
  1. Verify that the site works by opening a web browser and navigating to http://localhost:8000/.

  2. Stop the development server

  3. Collect static files:

python manage.py collectstatic
  1. Grant Full Permissions for web directory to IIS AppPool\DefaultAppPool

  2. Go to IIS Manager

  3. Add Virtual Directory to Static Folder

  4. Unlock the configuration manager

  5. Move web.config to parent directory c:\inetweb\wwwroot\

  6. Restart the WebSite

That's it! Your Django application should now be deployed and running on IIS.

gcp-django-demo's People

Contributors

ryancheley avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.