IIS上的Python:怎么样? [英] Python on IIS: how?

查看:733
本文介绍了IIS上的Python:怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有PHP,dotNet的背景,并被Python迷住了。我想逐步将功能从PHP转换到Python,并排运行点点滴滴。在此过渡期间,自应用程序庞大以来可能需要2年时间,我将被绑定到IIS。我有15年的网络编程背景,包括在IIS上的ISAPI模块中的一些C工作,这是我不想再深入研究的工作。

I've got a background in PHP, dotNet and am charmed by Python. I want to transpose functionality from PHP to Python step by step, running bits and pieces side-by-side. During this transition, which could take 2 years since the app is enormous, I am bound to IIS. I've got 15 years background of web-programming, including some C work in an ISAPI module on IIS which is the kind of work I don't want to dive into any more.

似乎Python在IIS上运行不佳。我一直在努力使用FastCGI(不支持,仅适用于PHP)和 PyIsapie (记录严重,无法启动并运行)。最后我得到了它并使用HeliconZoo dll运行但是:

It seems Python just doesn't run well on IIS. I've struggled with FastCGI (not supported, just for PHP) and PyIsapie (badly documented, couldn't get it up and running). In the end I got it up and running with a HeliconZoo dll BUT:

我的下一个问题是:如何调试/开发网站?在PHP中,您安装了一个调试器,每当您的网站出现问题时,您只需调试它,设置断点,逐步执行代码,检查手表等。在我看来,对于开发人员或疑难解答来说,这是最基本的工作类型。我买了WingIDE这是一个很好的工具和调试器,但由于某些原因它无法挂钩到IIS进程中的Python实例,所以没有调试。我注意到Helicon使用 -O 启动Python,所以我甚至重新编译了Python以完全忽略这个标志,但我的调试器(WingIDE)不会出现。

My next problem is: how to debug/develop a site? In PHP you install a debugger and whenever you have a problem in your website, you just debug it, set a breakpoint, step through code, inspect watches and such. It seems to me this is the most rudimentary type of work for a developer or troubleshooter. I've bought WingIDE which is an excellent tool and debugger but it can't hook into the Python instance in the IIS process for some reason so no debugging. I noticed Helicon starts Python with -O so I even recompiled Python to ignore this flag altogether but my debugger (WingIDE) just won't come up.

我可以在半小时内在IIS上建立一个PHPhello world网站,包括下载时间。我想我已经花了大约120个小时或更长时间才能让Python工作无济于事。我已经购买了 Programming Python Learning Python ,大约有3000页。我用Google搜索直到我放弃了。

I can set up a PHP 'hello world' website on IIS in half an hour including download time. I think I've spent about 120 hours or more getting this to work for Python to no avail. I've bought Programming Python and Learning Python which is about 3000 pages. And I've googled until I dropped.

我认为Python是一种很棒的语言,但我正处于中止尝试的边缘。是否有人可以给我一个关于如何在IIS7上进行设置的分步说明?

I think Python is a great language but I'm on the verge of aborting my attempts. Is there anyone who can give me a step-by-step instruction on how to set this up on IIS7?

推荐答案

我只是在5分钟内做到了这一点。

I just did this in 5 minutes.


  1. 确保您拥有IIS。运行:%windir%\system32 \ OptionUfeal.exe 。或者,通过尖头点击:开始...控制面板...程序和功能...(然后在左侧)打开或关闭Windows功能。确保在IIS节点下安装了CGI。

  1. Insure you have IIS. run: %windir%\system32\OptionalFeatures.exe. Or, via pointy-clicky: Start...Control Panel...Programs and Features... (and then on the left hand side) Turn Windows Features on or Off. Make sure CGI is installed, under the IIS node.

从Python下载Python ,来自python.org。我抓住了Python2.7。如果您有x64版本的Windows,请确保获得x64版本。

Download Python for Windows, from python.org . I grabbed Python2.7. Make sure you get the x64 version if you have an x64 version of Windows.

解压缩并安装该python MSI。选择默认值,将python放入 c:\ Pepy27

Unpack and install that python MSI. Choose the default, which puts python into c:\Python27

创建一个目录来保存你的开发python脚本。例如, c:\ dev\python

Create a directory to hold your "development" python scripts. Eg, c:\dev\python

设置目录中文件的权限 c:\dev\python 允许IIS读取和执行。通过从命令行运行这两个icacls.exe命令来执行此操作:

Set the permissions on the files in the directory c:\dev\python to allow IIS to read and execute. Do this by running these two icacls.exe commands from the command line:

cd \dev\python
icacls . /grant "NT AUTHORITY\IUSR:(OI)(CI)(RX)"
icacls . /grant "Builtin\IIS_IUSRS:(OI)(CI)(RX)"


  • 打开IIS管理器。运行%windir%\system32 \inetsrv \ iis.msc ,或通过控制面板执行此操作:开始...控制面板...管理工具.. .Internet Information Services(IIS)Manager。创建一个新的应用程序将虚拟路径指定为 / py ,将物理路径指定为 c:\dev\python

  • Open IIS manager. Run %windir%\system32\inetsrv\iis.msc, or do this via the control panel: Start...Control Panel...Administrative Tools...Internet Information Services (IIS) Manager. Create a new application. Specify the virtual path as /py and the physical path as c:\dev\python.

    在该IIS应用程序中,为 *。py 添加脚本映射,并将其映射到 c:\ python27 \ python.exe%s%s

    Within that IIS application, add a script map for *.py, and map it to c:\python27\python.exe %s %s

    c:\dev\python 中创建一个HelloWorld.py文件这是内容:

    create a "HelloWorld.py" file in c:\dev\python with this as the content:

    print('Content-Type: text/plain')
    print('')
    print('Hello, world!')
    


  • 调用 http://localhost/py/helloworld.py

    这篇关于IIS上的Python:怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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