| 1 | == Goals == |
| 2 | |
| 3 | The aim of this page is to describe getting Django to run on Windows, served by IIS and with an SQL Server backend. |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | Steps: |
| 8 | |
| 9 | * Install Python |
| 10 | * Install Python's Windows extensions |
| 11 | * Install an ISAPI extension for IIS |
| 12 | * Install Django |
| 13 | * Configure Django to look at SQL Server |
| 14 | * Test |
| 15 | * Celebrate |
| 16 | |
| 17 | == Installing Python == |
| 18 | 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. |
| 19 | |
| 20 | == Install Win32 extensions for Python == |
| 21 | These are some Windows specific extensions for Python, and they are (I think) required for the IIS driver later. |
| 22 | |
| 23 | Visit https://sourceforge.net/projects/pywin32/ and download the Windows installer, run through it. |
| 24 | ( 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 ) |
| 25 | |
| 26 | == Install an ISAPI extension for IIS == |
| 27 | 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. |
| 28 | |
| 29 | 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. |
| 30 | |
| 31 | Documentation is in the readme files, but at the time of writing the install is: |
| 32 | |
| 33 | * Copy the PyISAPIe.dll file to your Python path, e.g. c:\python24 |
| 34 | * 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 |
| 35 | * 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) |
| 36 | * 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. |
| 37 | * 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. |
| 38 | |
| 39 | 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 |
| 40 | |
| 41 | It should work. If it doesn't, when you find out why please come back and explain what happened and how you fixed it. ;) |
| 42 | |
| 43 | The PyISAPIe extension has a driver for Django as well, so that's where I will be heading next. |
| 44 | |
| 45 | == Install Django == |