IIS Not Linking to Django with PyISAPIe

一世执手 提交于 2019-12-04 11:51:46

Here are the original instructions I followed,

basics instructions: https://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer additional tips: http://whelkaholism.blogspot.ca/

  1. The first thing you should do is install Python 2.5 or 2.6, for 2.7 you need to recompile PyISAPIe, which I have not done. http://www.python.org/ftp/python/2.6/python-2.6.msi
  2. You need to install the version of PyISAPIe that will match your Python Interpreter version, if they do not match, it will fail. Get it there : http://sourceforge.net/projects/pyisapie/files/pyisapie/
  3. Move the extracted folder from the last step at a decent location (i.e. C:)
  4. You need to change the security settings of the PyISAPIe.dll, they suggest Network Service read, but I set everyone, to be sure there are no problems with this
  5. You then have to CUT AND PASTE (Important) the Http folder of PyISAPIe to Lib\Site-Packages of your Python installation directory
  6. Next, you setup IIS (open the manager with inetmgr in run (winkey+r):
    • Add a new virtual directory and allow executing ISAPI extensions when prompted by the wizard
    • Add a new wildcard extension in the property of your virtual directory, untick file exist setting
    • Add Web Service Extension to IIS Manager pointing to the dll, ensure it is allowed
  7. From the PyISAPIe folder, copy examples\django\Isapi.py and paste it in Lib\Site-Packages\Http
  8. In Isapi.py, set the path (i.e. c:\inetpub\wwwroot\ web_site\ django_project ) and DJANGO_SETTINGS_MODULE (i.e. django_app .settings)
  9. When any change is done to your files, use iisreset in your command prompt to apply the changes

Here are some other things you might do

  • Ensure the path of your db file (if sqlite used) is okay
  • Do the same with template location settings
  • In your urls and html files, ensure the path start with the name you gave to your virtual directory alias (i.e. web_site in our example)

Finally, you may encounter difficulties with serving your CSS. If you have any troubles, tell me and I will update my post.

Serving Django with any webserver basically involves three key details:

  1. Telling the webserver, "I want you to serve content that is provided by this module that invokes python"
  2. Telling the python module, "I want you to execute python code using the details in this file"
  3. Telling the file, "I want you to use Django"

If you're getting a directory listing back for your Virtual Directory then it would seem that you should investigate the VD settings to make sure PyISAPIe is configured for that directory (key details #1).

From the article you mentioned:

  • Open the IIS Management Console, and create a new virtual directory, and allow executing ISAPI extensions when prompted by the wizard.

    • View the properties of the new folder and click on the "configuration" button (if it's greyed out, click 'create' first), then add a new wildcard extension (the lower box), locate the pyisapie.dll file and untick the "check that file exists" box.

    • In the IIS Manager, go to the "Web Service Extensions" section, and right click -> add new web service extension.

  • Give it a name (it doesn't matter what), add the pyisapie.dll fill as a required file and check the box to set the extension status to allowed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!