Windows Server 2008 (IIS7)中配置使用 Python 3.0

1.首先当然是下载Python 了,推荐安装 ActivePython 这里我用的是3.0版本
  安装后才了解Google App Engree目前服务器运行的是2.5版本
  这里下载: Windows x86 版本
  Windows x86
  Linux x86
  Linux x86_64
  Mac OS X (Universal)
  Solaris 8 SPARC
  Solaris 8 SPARC (64-bit)
  Solaris 10 x86
  AIX PowerPC
  HP-UX PA-RISC
  2.安装 ActivePython 就不用说了。一路Next >>
  3.IIS7 的控制管理器   ,在站点的ISAPI and CGI 限制 中配置 C:\Python30\Python.exe %s %s  
  4.在站点的 处理程序映射 中添加"*.py"到 C:\Python30\Python.exe %s %s 的映射
  5.添加IIS 中的默认文档
  6.打开你在IIS中添加网站的目录,找到 web.config
  注: (如网站目录含有空格,第1个%s加上双引号,改为"%s",否则运行时报找不到目录或文件的错误)
  修改为如下内容:
  <?xml version="1.0" encoding="UTF-8"?>
  <configuration>
  <system.webServer>
  <handlers>
  <add name="ActiveState3.0" path="*.py" verb="*" modules="CgiModule"
  scriptProcessor="C:\Python30\Python.exe %s %s" resourceType="Unspecified" />
  </handlers>
  </system.webServer>
  </configuration>
  7. 测试Python 是否可以正常工作了
  1)重新启动 IIS
  2) 编写一个测试 index.py 文档 ,放在网站目录下,内容如下:(为 Python3.0+ 代码,不向下兼容)
  print ('Status: 200 OK')
  print ('Content-Type: text/html')
  print ('')
  print ('<html><head><title>Hello Xeye</title></head>')
  print ('<body>')
  print ('<h1>Hello, Xeye!</h1>')
  print ('</body>')
  print ('</html>')
  3)打开浏览器。访问添加的网站,如果能看到如下的画面,恭喜,你的IIS7已经可以支持 Python 了

posted on 2013-05-26 12:07  一个石头  阅读(756)  评论(0)    收藏  举报