开发者

IIS Not Linking to Django with PyISAPIe

开发者 https://www.devze.com 2022-12-27 10:45 出处:网络
I\'m trying to run a site with Django on an IIS-based server. I followed all the instructions on the main site (http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer), and double check

I'm trying to run a site with Django on an IIS-based server. I followed all the instructions on the main site (http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer), and double checked it with a very good article (http://www.messwithsilverlight.com/2009/11/django-on-windows-server-2003-and-iis6/).

I successfully got as far as setting up IIS to read .py files. Following the main instructions, I can get the server to render Info.py. However, I can't seem to get IIS and Django to play nice. If, for instance, my Virtual directory is "开发者_JAVA百科abc", then if I go to "localhost/abc/", the browser simply shows me the content directory for that folder. Furthermore, if I have my urls set up so that "/dashboard/1" should bring me to a certain page, entering "localhost/abc/dashboard/1" gives me a "page cannot be displayed" error.

I'm fairly certain IIS simply isn't referencing or interacting with Django at all. Does anyone have any ideas how to fix this?

Thanks


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消