简体   繁体   English

IIS没有使用PyISAPIe链接到Django

[英]IIS Not Linking to Django with PyISAPIe

I'm trying to run a site with Django on an IIS-based server. 我正在尝试在基于IIS的服务器上运行Django站点。 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/ ). 我按照主站点上的所有说明( http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer ),并用一篇非常好的文章仔细检查了它( 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. 我成功地设置了IIS来读取.py文件。 Following the main instructions, I can get the server to render Info.py. 按照主要说明,我可以让服务器呈现Info.py. However, I can't seem to get IIS and Django to play nice. 但是,我似乎无法让IIS和Django玩得很好。 If, for instance, my Virtual directory is "abc", then if I go to "localhost/abc/", the browser simply shows me the content directory for that folder. 例如,如果我的虚拟目录是“abc”,那么如果我转到“localhost / abc /”,浏览器只会显示该文件夹的内容目录。 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. 此外,如果我设置了我的网址以便“/ dashboard / 1”将我带到某个页面,输入“localhost / abc / dashboard / 1”会给我一个“无法显示页面”的错误。

I'm fairly certain IIS simply isn't referencing or interacting with Django at all. 我相当确定IIS根本就没有引用Django或与Django进行交互。 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/ 基础知识说明: https//code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer其他提示: 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. 你应该做的第一件事是安装Python 2.5或2.6,对于2.7你需要重新编译PyISAPIe,我还没有。 http://www.python.org/ftp/python/2.6/python-2.6.msi 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. 您需要安装与您的Python解释器版本匹配的PyISAPIe版本,如果它们不匹配,它将失败。 Get it there : http://sourceforge.net/projects/pyisapie/files/pyisapie/ 到那里: http//sourceforge.net/projects/pyisapie/files/pyisapie/
  3. Move the extracted folder from the last step at a decent location (ie C:) 将提取的文件夹从最后一步移动到一个不错的位置(即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 你需要更改PyISAPIe.dll的安全设置,他们建议网络服务读取,但我设置了所有人,以确保没有这个问题
  5. You then have to CUT AND PASTE (Important) the Http folder of PyISAPIe to Lib\\Site-Packages of your Python installation directory 然后你必须将PyISAPIe的Http文件夹切割并粘贴 (重要)到Python安装目录的Lib \\ Site-Packages
  6. Next, you setup IIS (open the manager with inetmgr in run (winkey+r): 接下来,您设置IIS(在运行中使用inetmgr打开管理器(winkey + r):
    • Add a new virtual directory and allow executing ISAPI extensions when prompted by the wizard 添加新的虚拟目录,并在向导提示时允许执行ISAPI扩展
    • Add a new wildcard extension in the property of your virtual directory, untick file exist setting 在虚拟目录的属性中添加新的通配符扩展,untick文件存在设置
    • Add Web Service Extension to IIS Manager pointing to the dll, ensure it is allowed 将Web服务扩展添加到指向dll的IIS管理器,确保允许它
  7. From the PyISAPIe folder, copy examples\\django\\Isapi.py and paste it in Lib\\Site-Packages\\Http 从PyISAPIe文件夹中,复制examples \\ django \\ Isapi.py并将其粘贴到Lib \\ Site-Packages \\ Http中
  8. In Isapi.py, set the path (ie c:\\inetpub\\wwwroot\\ web_site \\ django_project ) and DJANGO_SETTINGS_MODULE (ie django_app .settings) 在Isapi.py中,设置路径(即c:\\ inetpub \\ wwwroot \\ web_site \\ django_project )和DJANGO_SETTINGS_MODULE(即django_app .settings)
  9. When any change is done to your files, use iisreset in your command prompt to apply the changes 对文件进行任何更改后, 在命令提示符中使用iisreset应用更改

Here are some other things you might do 以下是您可能会做的其他一些事情

  • Ensure the path of your db file (if sqlite used) is okay 确保db文件的路径(如果使用sqlite)没问题
  • 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 (ie web_site in our example) 在您的url和html文件中,确保路径以您为虚拟目录别名命名的名称(即我们示例中的web_site

Finally, you may encounter difficulties with serving your CSS. 最后,您可能会遇到服务CSS的困难。 If you have any troubles, tell me and I will update my post. 如果您有任何问题,请告诉我,我会更新我的帖子。

Serving Django with any webserver basically involves three key details: 使用任何网络服务器提供Django基本上涉及三个关键细节:

  1. Telling the webserver, "I want you to serve content that is provided by this module that invokes python" 告诉网络服务器,“我希望你提供这个模块提供的调用python的内容”
  2. Telling the python module, "I want you to execute python code using the details in this file" 告诉python模块,“我想让你使用这个文件中的细节执行python代码”
  3. Telling the file, "I want you to use Django" 告诉文件,“我希望你使用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). 如果您正在为虚拟目录获取目录列表,那么您似乎应该调查VD设置以确保为该目录配置PyISAPIe(关键详细信息#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. 打开IIS管理控制台,并创建一个新的虚拟目录,并在向导提示时允许执行ISAPI扩展。

    • 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. 查看新文件夹的属性,然后单击“配置”按钮(如果它显示为灰色,先单击“创建”),然后添加新的通配符扩展名(下方框),找到pyisapie.dll文件并取消勾选“检查该文件是否存在“框。

    • In the IIS Manager, go to the "Web Service Extensions" section, and right click -> add new web service extension. 在IIS管理器中,转到“Web服务扩展”部分,然后右键单击 - >添加新的Web服务扩展。

  • 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. 给它命名(无关紧要),将pyisapie.dll填充添加为必需文件,并选中复选框以将扩展状态设置为允许。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM