Deploy Django on Windows using Microsoft IIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so this is going to be a tutorial on how to deploy a django application onto a Windows Server using iis so in front of you in front of me I have a simple web app it has a form has some inputs and saves a data database outputs that data and has the option to download that data to excel so pretty straightforward and complicated I have the web app running right now I'm going to turn this office I don't need it alright so I have the web app and code and everything on get up so I'll post a link to the script in the description so you can download this but basically I've outlined some stuffs here so that you can follow along and deploy this web app on to a Windows VM or Windows server so the first thing that you'll need to is create a VM I'll be using Google cloud platform I'll create an instance change the OS to Windows and then what I'll be using will be the Windows Server 2008 Center I'm gonna hit cancel and cancel again because I already have a VM running so I'm just gonna open up that VM and get started okay so now I have my VM ready I'm gonna minimize this I'm going to open up Internet Explorer and what I wouldn't do first is install a new web browser because I don't like using Internet Explorer all right so I have a web browser that I want to use the first thing that I wouldn't do is download and install git bash and this is simply just to allow me to download my get repo and just make the experience on the windows command prompt a little easier all right now that git bash is installed I'm going to try to download my project repo and I'm actually going to save it right on desktop all right so I have a project here either I need to edit some of these files so what I'm going to do is I'm going to install a Visual Studio code all right so I've navigated to like hub repo and I'm just gonna follow along the steps that I've outlined here so the first thing to do is install I asked the VM so on here what I can do is see if I'm allowed to do this add roles and features next next next I want to click on web server I us add features next next next and what I need tense thought is I is so under application development I'm going to scroll down and hit CGI make sure that's chosen because this is what will will be needed in order to have our jingle web app to run and finally install once installation is complete just close the window and you can minimize that all right so we have is installed and we have CGI the next thing to do is a copy our web project over to this directory inet web root so it open up the drug tree local see I nut whatever rww root you can delete these files continue Taniya and I'm just gonna copy that over here didn't you okay so I'm going to open the folder up with Visual Studio code and again that's because I need to make a few edits all right to first make things a little clearer and what we're going to be editing and why I'm gonna go to Google and search for Django Windows us and the basic steps that are going to be taking are going to be outlined in this article configure pi thon Web Apps for is there should already be a link in the description here otherwise I'll include it but there is a some settings here that need to be included for your jingle web project most of the settings have already been applied in my project so but I'll kind of try to explain what needs to be edited alright so the first thing to begin with is that here is a web config template and after we're done editing this this is going to be turned into a web dot config file that will sit outside of our project directory so the first thing that we need to do is let's say we need install Python 3 7 so its search for download Python and I'm going to use three sound sound seven and actually will cancel this I'm kind of run it as administrator I want a custom install and I'm gonna put Python right on the C Drive so it's easy to access so now that pythons installed I am going to install my libraries so I'm gonna have a file here it's called install of a car and stop that I'm going to need W fast CGI but I'm not gonna need my whiskey so I'm going to delete that just for reference this mod whiskey was for a separate tutorial not relevant here so the next thing that I need to do is go to this foot project and actually I'm going to type in CMD to open up terminal and install requirement self at all right so it doesn't limit now that my libraries have been installed I'm gonna check the next step and next up is to navigate to the C Drive go to the Python 3 summary edit the properties and security settings to allow is Apple default app pool so here is where my Python install is setting and go to properties security edit add us pull default up pool and this default Apple is just something that I is creates it basically runs your application and so you need to give it permission to Python and your project so that it can run your application hello apply ok next thing to do is to enable W fast CGI so what we need to do is open up a terminal run as administrator and run the line they'll be fast CGI enable so I'm close this terminal open up a new one on the right click on the terminal and select run as administrator all right so the command that I want to run is W fast CGI enable [Music] okay that's not working let's look up Python W fast CGI okay I'm miss spelt it cool so what it returned was this pythonpath and we'll need to use this to update our our config file so back in Visual Studio code you want to open up this web config template go to the line that says a script processor and paste in that value other values that need to be updated include the Python path and that should point to your project directory if your project doesn't happen to sit in ww route make sure you update that path to whatever wherever the projects sitting the next thing is the whiskey handler and this can just easily be found in the whiskey dot PI file so for example if you go to under web project whiskey PI and find the application right there similarly for the Django sangs module that is simply your web project and then the settings so right here this setting stop I file an additional web config file will also be needed and I've already included it here in my static directory and this should just contain these settings without any editing so don't make any modifications to this web config file all right so this web config template is ready and I'm just going to rename it to web dot config and let's look back at the steps that are needed close out these extra tabs all right so we ran we enabled W fast CGI we've edited our web config template and renamed it web config however right now it's not sitting in this path it's sitting in our web project directory so I'm going to copy it and move it to ww so I cut uh WWE route and paste great and this is the location that Windows is we'll be looking for our config file that's why I need it paste it there the next thing that I need to do is open the IRS manager and enable handlers there so I'm just gonna click on this server click on configuration editor look for system web server and then handlers there we go and you just want to select unlock section and the reason for that is because our web config file is creating a header all right the next step is to add a virtual directory and that will actually be for our site so over here you should add something that says default site default website or something similar and what you need to do is right click on that and add virtual directory and this will be for our static files now that we have that set up I'm going to navigate on terminal to inet route and our web project now I'm going to need to call on manager up PI to collect our static files actually before I do that let me double check the settings file okay a few things you want to add the local path if you're just running this on a local VM its enter something like that or local host since I'm running this on the Google cloud platform I'll need my IP address and for me that's this number right here so I'm gonna copy that and paste it I'm gonna change debug to false let's go all the way at the bottom to change my static route all right so now when I call collect static it should paste all my static clouds into the static directory all right so I can inspect that everything was pasted in here you can see that this is all in green and this is just I get identifying any changes close that out I don't think I need to make any more changes but I'll keep just suit open just in case all right the next thing to do is to refresh the server and navigate to localhost and you can just do this over here so click on the default web server website or whatever you have this cult and click restart and then I'm just going to open up a bright window and you can see that my web application is now being served I'm just going to test this out oh we have a server 500 error I wonder why that is server 500 err let me see I'm just going to check the settings here I might need to add I asked pool default for the issue might be that I is uphold my only have permissions to read and not modify since I'm saving to a database I need to give it right permissions all right so I'm going to restart the server and then I'm going to navigate to localhost again and try this again and you can see that fixed it so I have this additional record made on May 12th and to test it out again four five six see that I can not continually add on to that and you can see that I could also download my data as an Excel workbook the last thing that I want to show you is how to serve this to the public so the first thing we need to do is look at our firewall settings let's go to advanced settings go to inbound rules and we're going to add a new rule select port type in port 80 and I will just call this world World Wide Web accident I'm just going to restart our server minimize this window I'm just going to minimize the VM so here on my local machine I'm going to navigate to this external IP address actually sometimes this works faster if I just open up a new private tab and you can see here that I have my web application you can see that the two edits that I've made are also included in here acknowledging that everything is working good cool right so that's those are the basic steps to getting your Django web application to run on windows iis thanks
Info
Channel: Johnnyboycurtis
Views: 25,578
Rating: undefined out of 5
Keywords: Python, Django, Deploy, Windows IIS, Windows Web Server, Google Cloud, Microsoft IIS, Windows 10, Windows Server
Id: APCQ15YqqQ0
Channel Id: undefined
Length: 22min 34sec (1354 seconds)
Published: Fri May 22 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.