Running Django on Windows Using an IIS Server

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello my name is Derrick Allen and today I'm going to set up Windows iis server to run Django I will be using Windows Server 2016 to do this project so anyways let's get started first thing you need to do is go and download Python for your Windows server so crank up your browser and hit on there with your python.org and then click the Downloads link and then click the version you want I have chosen to use Python 3 just save it after python has downloaded it going to the folder and then right click and then click on run as administrator click yes then I'm going to use a custom install I'm going to check to have Python environmental variables install for me and then I'm going to choose a different folder where I want my Python to be located and I want changed the Python folder named after you have done this click the install and let the installation process begin now that Python is installed I'm going to close out on top of these windows to get them out my way so just hold on for one second okay now that is done that's the right click on PowerShell and then run as administrator click yes let's type in Python to make sure that Python was installed correctly which it seems to be type exit to get out of the Python shell okay we are going to install a few things we need to install w fast CGI and Django so pip install W fast CGI hit enter let it install then pip install Django and I'm going to install version 1 point at 11 because that's what my Python was done in I'm a Python but my Django project so after typing in pip install Django equals one point 11 hit enter and let the installation process begin okay now that w passed CGI is installed let's enable it so at the PowerShell prompt type in W fast CGI minus sign enable and then hit enter and this will enable W fast CGI for us with that said I'll pay attention to this section right here because we are going to use it in our web dot to pig valve that we are getting ready to create alrighty go down to your windows search then type in window feature and then click on the window feature program I'm just doing this to make sure that CGI is installed you should do the same make sure that you have the CGI feature installed on your iis server ok go to your web server and then go to application development then scroll down a little bit just to see if CGI is installed if it is not installed click the box next to the CGI and then install it now that is out the way it's time to create that web that could pick Val so mosey on over to your root directory of your website which is www.hyken.com out create it I'm going to use Visual Studio code to open this up and show you the content once the file is open pay attention to the script processor value this has to be the same as the output from the WC g i-- - enable command we used as you can see right here I'm going to leave mine the way it is just to demonstrate an error that will happen if you do not have this correct but these two values should be the same now let's look at the handler value which is right here we can get this value back going to our Django project and opening up the settings file once it is open just scroll down to where it says wsgi application and copy that value that you have there and then insert it into your web data pick Val so let's copy this and then insert it into our web deck a big map if you notice underneath my handler we have a Python path this is the path to our Django project so just insert the path to your Django project for that value then you have some optional settings there's more than these settings here for your optional settings the value here is just a name of your project then dot settings okay now that's not the way this file should be saved into your root directory which mine is WWWE save this as a web config file now that we have cleared that I'm going to CD into my jingo project which is just John then I'm going to collect all my static files by using Python manage collect static now that I have collected all of my static files I'm going to go to that folder and then create another web that config file which I am going to just drag and drop it into that water because I haven't already created okay now let's open up this file this file pretty much overrides the fast cgi handler it allows the iis server to serve the static files so make sure you create another web duct to pick pal which has this content in it and place it in the static folder alrighty that's all there is to that let's just close this out or lower it and let's go back to a root directory okay now I'm going to open up my server manager and then open up iis [Music] now that is open I'm going to click over here in the pane so I can see my site and things of that nature also I will have to come back here in a minute because I'm getting ready to load the site up or hit the Refresh or go to localhost and try to run the site like it is which one I do run it on localhost you will see that I get an error here 500 error if you get this type of error this means that you need to unlock your handlers to unlock your handlers go to your system root which is above your application pool and then click on configure editor so a configuration editor then click the system dot webserver and then go to handler now to your right you will see where it says unlock section click one where it says unlock section after clicking unlock section you should see now lock section alrighty let's refresh this page and see what happens ok we can see that we solved one era but we have another this other error is due to a fact that my script processor value isn't that correct and that I is does not have permission to my Python file so I'm going to go over here and correct that real quick ok opening up my web config file so I can correct that script processor value as you can see is incorrect this is the value it should be so I'm going to copy this and paste it into my web that Copic Val now that I have it correct at that value just go up here and save the file now let's go give iis permission to access my python file now that I'm at my Python I'm going to right click and go to properties and then security damn along click Edit and then add and I'm going to type and I is at pull slash default at pool then we'll click on check name yep is correct and click OK click apply let it let it do its thing click OK and ok and that should be good and now refresh and bam we have added jingo sorry we have a Jingu site although we have a Django site up and running it is not just playing our static files there's no CSS or anything but we can fix that alrighty to fix this problem open up your eye is manager and then go to your website - the default website and right click and then go to create virtual directory type your alias as static or whatever you choose or want and then put the path to the static file okay then restart your server and refresh and bam you have a complete Ginga website with all the static files being served by iis on that note if you are interested in the web ductile thick file that was used you can go to python org slash pi pi / w fast cgi with that said I am out and see you next time
Info
Channel: DATJot
Views: 35,849
Rating: undefined out of 5
Keywords: django, windows, iis, server, programming, python
Id: CpFU16KrJcQ
Channel Id: undefined
Length: 13min 5sec (785 seconds)
Published: Sat Dec 30 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.