|Version 1 (modified by anonymous, 8 years ago) (diff)|
The aim of this page is to describe getting Django to run on Windows, served by IIS and with an SQL Server backend.
Useful for people who already have such a setup (You wont find me discussing the installation of SQL Server here) and can't justify (or just don't want) Apache and PostgreSQL as well.
- Install Python
- Install Python's Windows extensions
- Install an ISAPI extension for IIS
- Install Django
- Configure Django to look at SQL Server
Head to http://www.python.org/ and look at the menu on the left; in the "quick links" section is a link to the Windows installer for the latest stable version of Python. Download and run it, following the wizard steps until it is complete.
Install Win32 extensions for Python
These are some Windows specific extensions for Python, and they are (I think) required for the IIS driver later.
Visit https://sourceforge.net/projects/pywin32/ and download the Windows installer, run through it. ( That URL looks neater, but the download link gives Error 500 at the moment. This one seems to work though: http://sourceforge.net/project/showfiles.php?group_id=78018 )
Install an ISAPI extension for IIS
This is an extension that loads the Python interpreter into memory while IIS is running, and uses it to serve requests more quickly. CGI apps need to start a new instance of the interpreter for every request, this does not have that overhead - it performs a similar service to mod_python on Apache servers.
Go to http://pyisapie.sourceforge.net/ and download it (look in the menu on the right, under "Links" for a download link). Unzip the archive so you can copy files out of it.
Documentation is in the readme files, but at the time of writing the install is:
- Copy the PyISAPIe.dll file to your Python path, e.g. c:\python24
- Set the security permissions on the dll file so that IIS can read it. In the case of IIS/Server 2003 you need to give read permissions to the "Network Service" account
- Look in the <extracted archive>\source\PyISAPIe\Python\ folder and copy the Http folder to c:\python24\lib\site-packages (adjust, depending on where you installed Python)
- Open the IIS Manager from Administrative Tools, and create a new virtual directory in your website (give it permissions to execute ISAPI extensions when the wizard asks.
- Go to the properties of the folder, click on the configuration button (if it's greyed out, click 'create' first), and add a new wildcard extension (the lower box), locate the pyisapie.dll file and untick the "check file exists" box.
That's it installed. In the <extracted archive>\source\PyISAPIe\Python\examples folder is a file called Info.py. Copy this to your new virtual directory folder, and then try and view http:// your site / info.py
It should work. If it doesn't, when you find out why please come back and explain what happened and how you fixed it. ;)
The PyISAPIe extension has a driver for Django as well, so that's where I will be heading next.