IIS不使用PyISAPIe链接到Django [英] IIS Not Linking to Django with PyISAPIe

查看:275
本文介绍了IIS不使用PyISAPIe链接到Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在基于IIS的服务器上使用Django运行一个站点。我遵循主站点上的所有说明( http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer ),并用一个非常好的文章( http://www.messwithsilverlight.com/2009/11/django-on-windows-server-2003-and-iis6/ )。



我成功地将IIS设置为读取.py文件。按照主要指示,我可以让服务器呈现Info.py。但是,我似乎不能让IIS和Django玩得很好。例如,如果我的虚拟目录是abc,那么如果我去localhost / abc /,那么浏览器只会显示该文件夹的内容目录。此外,如果我设置了我的网址,以便/ dashboard / 1将我带到某个页面,输入localhost / abc / dashboard / 1会给我一个页面无法显示错误。



我相当确定IIS根本没有引用或与Django进行交互。有没有人有任何想法如何解决这个问题?



谢谢

解决方案

以下是我遵循的原始说明,



基本说明: https://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer
附加提示: http: //whelkaholism.blogspot.ca/


  1. 你应该做的第一件事是安装Python 2.5或2.6,为2.7需要重新编译PyISAPIe,我还没做。 http://www.python.org/ftp/python/2.6/python -2.6.msi

  2. 您需要安装与您的Python解释器版本匹配的PyISAPIe版本,如果它们不匹配,则会失败。得到它: http://sourceforge.net/projects/pyisapie/files/pyisapie/

  3. 将提取的文件夹从最后一步移动到合适的位置(即C:)

  4. 您需要更改安全设置PyISAPIe.dll,他们建议网络服务读取,但我设置每个人,以确保没有问题这个

  5. 然后你必须 CUT AND PASTE (重要)PyISAPIe的Http文件夹到您的Python安装目录的Lib \Site-Packages

  6. 接下来,您设置IIS(在运行中打开具有 inetmgr 的管理器(winkey + r):

    • 添加新的虚拟目录,并允许在向导提示时执行ISAPI扩展

    • 添加新的通配符在虚拟目录的属性中的扩展名,untick文件存在设置

    • 将Web服务扩展添加到指向dll的IIS管理器,确保它是allowe d


  7. 从PyISAPIe文件夹复制examples\django\Isapi.py并将其粘贴到Lib \Site-Packages \\ \\ Http

  8. 在Isapi.py中,设置路径(即c:\inetpub\wwwroot\ web_site \ django_project )和DJANGO_SETTINGS_MODULE(即 django_app .settings)

  9. 对文件进行任何更改时,请在命令提示符下使用 iisreset 应用更改

这里还有其他一些您可能会做的事情




  • 确保您的数据库文件的路径(如果使用sqlite)是好的

  • 对模板位置设置执行相同操作

  • 在您的urls和html文件,确保路径以您给虚拟目录别名(即我们的示例中的 web_site )的名称开始



最后,您可能会遇到服务您的CSS的困难。如果你有麻烦,告诉我,我会更新我的帖子。


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 "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.

这篇关于IIS不使用PyISAPIe链接到Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆