PyISAPIe是一个IIS的ISAPI扩展,可以使IIS运行python脚本做的网站程序。

pyisapie的下载,就不介绍了。google解决。

安装,先解压到C:\pyisapie\,然后把Http目录复制到site-packages目录下即可。

右键单击c:\pyisapie\pyisapie.dll,选属性,然后在安全选项卡中,加入Network service和IIS_USERMACHINENAME(IIS用户访问账号,一定要加,不然,会要求你登录认证)

IIS中的配置,新建一个网站,主目录中的路径指向你喜欢的任意目录,然后在主目录的选项卡,点配置按钮,在弹出的框子中,在通配符的那个框框旁边,点添加,选中c:\pyisapie\pyisapie.dll,然后勾掉“确认文件是否存在”,不要选中这个。

新建web服务扩展,在扩展名(实际是扩展服务的名称,不是我们所知道的文件扩展名的意思,IIS中文翻译的问题),随意填写,然后在文件的框框旁边点击插入按钮,选择c:\pyisapie\pyisapie.dll文件就行了。

新建一个应用程序池,名字随意,比如取名为django test,建好后,右键选属性,然后把它设置为60分钟回收和1次请求后回收(目的是让它每次http请求后就重新加载代码),具体多少按照自己的喜好来。

将上面提到的Http目录中的Isapi.py文件修改为一下内容:

view plaincopy to clipboardprint?
# $URL: https://pyisapie.svn.sourceforge.net/svnroot/pyisapie/Tags/1.1.0-rc4/PyISAPIe/Python/Http/Isapi.py $  
# $Rev: 165 $ $Date: 2009-06-15 14:19:18 -0700 (Mon, 15 Jun 2009) $  
# (C)2008 Phillip Sitbon <phillip@sitbon.net>  
#  
"""Global ISAPI request handler. 
 
All requests go here - after the first successful 
import of this module & Request() function, it 
will not be reloaded for the life of the interpreter. 
 
This default simply attempts to load the file targeted 
by the URL and call its Request() function. Although 
SCRIPT_TRANSLATED is not available in IIS 5.x, it is 
emulated for completeness. 
 
I don't really recommend this method - it's not as 
package/module oriented as the Regex and Advanced 
examples, which can handle arbitrary URLs and pass 
them to preloaded handlers. 
 
ALSO: imp.load_source is NOT case-sensitive and doesn't 
follow the typical import case rules. You might like this 
but it's really not great behavior. 
 
See example Isapi.py files in ../Examples, including 
one that makes this version backwards compatible with 
v1.0.0 (in the Compat folder). 
""" 
from django.core.handlers.wsgi import WSGIHandler as DjangoHandler  
from Http.WSGI import RunWSGI  
from Http import Env  
import os  
import sys  
##############the 2 lines under is not nessery##############  
#sys.path.append('C:\\Python25\\Lib\\site-packages')  
#sys.path.append('C:\\Python25\\Lib\\site-packages\\django')  
############################################################  
 
#sys.path.append('F:\\Website\\Projects\\ysdy\\trunk\\')  
#sys.path.append('F:\\Website\\Projects\\ysdy\\trunk\\ddtcms')  
sys.path.append('E:\\')#fat32  
sys.path.append('E:\\ddtcms')#fat32  
 
#sys.path.append('F:\\')  
#sys.path.append('F:\\ddtcms')  
 
#sys.path.append('E:\\')  
#sys.path.append('E:\\mysite')  
 
 
os.environ["DJANGO_SETTINGS_MODULE"] = "ddtcms.settings" 
# os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"  
# This is how the WSGI module determines what part of the path  
# SCRIPT_NAME should consist of. If you configure PyISAPIe as  
# a wildcard map on the root of your site, you can leave this  
# value as-is.  
#   
Base = "/" 
 
# This is an example of what paths might need to be handled by  
# other parts of IIS that still come here first. This value's  
# default of "/media" assumes that you've mapped a virtual  
# directory to Django's admin media folder and so expect the  
# files to be served by the static file handler.  
#  
Exclude = ["/media"]  
 
 
 
# The main request handler.  
# This object can be re-created for every request if desired.  
#  
Handler = DjangoHandler()  
 
def Request():  
  PathInfo = Env.PATH_INFO  
    
  # There is no way to test if this ISAPI extension is configured  
  # as a wildcard handler, so this script will fail if it is not.  
  # If you'd rather have it as a script map, remove the checks below.  
  #  
  # You can also remove it if you set up this instance as a handler  
  # for a virtual directory and know that Base will always start  
  # with it. For example, if "/django_site_1" is the virtual directory  
  # you're running in, and Base is set to the same value, no need  
  # to ever pass control away from this handler.  
    
  # Pass through to the next handler if it's not  
  # part of our Django app.  
  #  
  if not PathInfo.startswith(Base):  
    return True 
 
  # Check for anything we know shouldn't be handled by Django and  
  # pass it back to IIS, which in most cases sends it to the static  
  # file handler.  
  #  
  for Excl in Exclude:  
    if PathInfo.startswith(Excl):  
      return True 
 
  return RunWSGI(Handler, Base=Base) 
# $URL: https://pyisapie.svn.sourceforge.net/svnroot/pyisapie/Tags/1.1.0-rc4/PyISAPIe/Python/Http/Isapi.py $
# $Rev: 165 $ $Date: 2009-06-15 14:19:18 -0700 (Mon, 15 Jun 2009) $
# (C)2008 Phillip Sitbon <phillip@sitbon.net>
#
"""Global ISAPI request handler.

All requests go here - after the first successful
import of this module & Request() function, it
will not be reloaded for the life of the interpreter.

This default simply attempts to load the file targeted
by the URL and call its Request() function. Although
SCRIPT_TRANSLATED is not available in IIS 5.x, it is
emulated for completeness.

I don't really recommend this method - it's not as
package/module oriented as the Regex and Advanced
examples, which can handle arbitrary URLs and pass
them to preloaded handlers.

ALSO: imp.load_source is NOT case-sensitive and doesn't
follow the typical import case rules. You might like this
but it's really not great behavior.

See example Isapi.py files in ../Examples, including
one that makes this version backwards compatible with
v1.0.0 (in the Compat folder).
"""
from django.core.handlers.wsgi import WSGIHandler as DjangoHandler
from Http.WSGI import RunWSGI
from Http import Env
import os
import sys
##############the 2 lines under is not nessery##############
#sys.path.append('C:\\Python25\\Lib\\site-packages')
#sys.path.append('C:\\Python25\\Lib\\site-packages\\django')
############################################################

#sys.path.append('F:\\Website\\Projects\\ysdy\\trunk\\')
#sys.path.append('F:\\Website\\Projects\\ysdy\\trunk\\ddtcms')
sys.path.append('E:\\')#fat32
sys.path.append('E:\\ddtcms')#fat32

#sys.path.append('F:\\')
#sys.path.append('F:\\ddtcms')

#sys.path.append('E:\\')
#sys.path.append('E:\\mysite')

os.environ["DJANGO_SETTINGS_MODULE"] = "ddtcms.settings"
# os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
# This is how the WSGI module determines what part of the path
# SCRIPT_NAME should consist of. If you configure PyISAPIe as
# a wildcard map on the root of your site, you can leave this
# value as-is.
#
Base = "/"

# This is an example of what paths might need to be handled by
# other parts of IIS that still come here first. This value's
# default of "/media" assumes that you've mapped a virtual
# directory to Django's admin media folder and so expect the
# files to be served by the static file handler.
#
Exclude = ["/media"]

# The main request handler.
# This object can be re-created for every request if desired.
#
Handler = DjangoHandler()

def Request():
  PathInfo = Env.PATH_INFO
 
  # There is no way to test if this ISAPI extension is configured
  # as a wildcard handler, so this script will fail if it is not.
  # If you'd rather have it as a script map, remove the checks below.
  #
  # You can also remove it if you set up this instance as a handler
  # for a virtual directory and know that Base will always start
  # with it. For example, if "/django_site_1" is the virtual directory
  # you're running in, and Base is set to the same value, no need
  # to ever pass control away from this handler.
 
  # Pass through to the next handler if it's not
  # part of our Django app.
  #
  if not PathInfo.startswith(Base):
    return True

# Check for anything we know shouldn't be handled by Django and
  # pass it back to IIS, which in most cases sends it to the static
  # file handler.
  #
  for Excl in Exclude:
    if PathInfo.startswith(Excl):
      return True

return RunWSGI(Handler, Base=Base)

这个其实就是examples目录下的django文件夹中的那个isapi.py 文件的修改。

完成了之后,在你新建的网站上的主目录选项卡,选中应用程序池为djangotest。

然后就可以在django test 的应用程序池上,右键选回收。

然后在ie中浏览你的网站地址即可。

E:\ddtcms 是我的项目根目录,加入E:到sys.path是因为ddtcms在E:目录下,不加E:\话,ddtcms.settings

就找不到。

现在的问题是,你的django项目所在的硬盘分区必须是fat32的,ntfs的不行,我不知道为什么,因为我把network service和IIS_USer都加到了项目路径的,采用了完全控制的权限,都不行,甚至连everyone都是完全控制的。还是不行,看来是人品的问题。

下面是出错的信息:

Internal Server Error
An error occurred processing this request.

--------------------------------------------------------------------------------

Request handler failed

Traceback (most recent call last):
File "C:\Python25\lib\site-packages\Http\Isapi.py", line 102, in Request
return RunWSGI(Handler, Base=Base)
File "C:\Python25\lib\site-packages\Http\WSGI.py", line 155, in RunWSGI
Result = Application(Environ, StartResponse)
File "C:\Python25\lib\site-packages\django\core\handlers\wsgi.py", line 230, in __call__
self.load_middleware()
File "C:\Python25\lib\site-packages\django\core\handlers\base.py", line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "C:\Python25\lib\site-packages\django\utils\functional.py", line 269, in __getattr__
self._setup()
File "C:\Python25\lib\site-packages\django\conf\__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python25\lib\site-packages\django\conf\__init__.py", line 75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'ddtcms.settings' (Is it on sys.path? Does it have syntax errors?): No module named ddtcms.settings

Additional Information

--------------------------------------------------------------------------------

-- Module Search Path --

C:\PyISAPIe-1.1.0-rc4-Py2.5
C:\WINDOWS\system32\python25.zip
C:\Python25\Lib
C:\Python25\DLLs
C:\Python25\Lib\lib-tk
c:\windows\system32\inetsrv
C:\Python25
C:\Python25\lib\site-packages
C:\Python25\lib\site-packages\PIL
C:\Python25\lib\site-packages\win32
C:\Python25\lib\site-packages\win32\lib
C:\Python25\lib\site-packages\Pythonwin
F:\
F:\ddtcms

-- Other Path Info --

Current Directory = 'C:\PyISAPIe-1.1.0-rc4-Py2.5'
Python Home = '<Auto>'
sys.executable = 'C:\PyISAPIe-1.1.0-rc4-Py2.5\PyISAPIe.dll'
sys.exec_prefix = 'C:\Python25'
sys.prefix = 'C:\Python25'

还有一个就是你必须装好vc9.0 CRT 运行库,google找到并安装吧,因为c:\pyisapie\pyisapie.dll是vc 9.0编译的。

最好装好pywin32,以便支持ISAPI,还有可能的话装上wsgiref。

祝大家好运。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/huyoo/archive/2009/12/30/5108673.aspx

转载于:https://www.cnblogs.com/nick4/archive/2009/12/30/1636369.html

[转载]windows2003上IIS+PyISAPIe1.1..0部署成功相关推荐

  1. Win2008上.NET4.0部署出错HTTP 错误 500.21 - Internal Server Error的解决方法

    Win2008上.NET4.0部署出错HTTP 错误 500.21 - Internal Server Error的解决方法 参考文章: (1)Win2008上.NET4.0部署出错HTTP 错误 5 ...

  2. 项目部署到tomcat6.0启动成功后访问页面报500_.net core IIS部署教程

    今天上午基于.net core做了一个简单的Web Api的Demo,练习一下IIS部署,本以为很简单,没想到遇到了很多坑,折腾了大半天才部署成功,简单记录一下,以供大家参考. 1.发布项目 2.下载 ...

  3. mysql上传到阿里云服务器地址_从0部署Web项目到阿里云服务器上

    前言 本篇文章的主要内容正如标题所言,这个过程说简单也还是有很多细节需要注意的,说难其实也挺简单的,还是希望我们大家都能勤动手去体会其中的内容,经历本身就可以使人进步.话不多说,让我们开始吧. 正文 ...

  4. 全网最新 Skywalking 6.1.0部署进k8s 包含springcloud测试用例

    skywalking-kubernetes 该项目可以迅速将skywalking 6.1.0部署进kubernetes(k8s) 包含ui oap es模块和完整的springcloud测试用例 此外 ...

  5. Win7 IIS7 ASP.NET MVC3.0 部署问题

    Win7 IIS7 ASP.NET MVC3.0 部署问题 1.应用程序池采用经典模式,framework4.0.可能存在权限问题,解决办法:在高级设置的标识设为LocalSystem. 一般mvc都 ...

  6. Zabbix 3.0 部署监控 [三]

    Zabbix 3.0 部署监控 [三] zabbix  时间:2016年9月22日  笔者QQ:381493251  Abcdocker交流群:454666672  如果遇到什么问题可以进群询问,我们 ...

  7. Istio 1.0 部署

    原文链接:Istio 1.0 部署 北京时间 2018 年 8 月 1 日(建军节)凌晨 0 点,Istio 宣布推出 1.0 正式版本,并表示已可用于生产环境.这距离最初的 0.1 版本发布已过去一 ...

  8. IIS之web服务器部署

    文章目录 IIS之web服务器部署 一.在windows2003上安装web服务器 二.新建一个站点 三.在服务器上配置多个站点的方法 四.不同的ip,相同的端口 五.相同的ip,不同的端口 六.相同 ...

  9. 如何上传图片到fileupload空间_如何用原生js写图片上传组件v2.0(还有新版本)?...

    js图片上传组件: 基本要求: 1.上传的图片可预览,可删除,可被覆盖更新 2.要求图片格式为jpg和png,大小不能超过2M 新加需求: 1.模拟回显,可用本地存储(实际上的回显是通过后台传过来的u ...

最新文章

  1. 当 python Pip 升级失败
  2. 前端开发浏览器兼容问题
  3. #ifdef _DEBUG #define new DEBUG_NEW #endif的解释
  4. 电压kV为什么k要小写,原因你知道吗?
  5. microbit编程_使用图形化编程实现主控板与手机蓝牙通讯(2019.3.25)
  6. 高薪招聘生物信息工程师-中国科学院深圳先进技术研究院合成所合成生物大设施...
  7. Conversion of Continuous-Valued Deep Networks to Efficient Event-Driven Networks for Image
  8. 5G/NR 学习笔记:波束赋形 / beam 管理
  9. 【QT】QT从零入门教程(十七):QT+OpenCV+VS 打包exe
  10. 8.0魔兽服务器维护时间,魔兽世界8.0大米开放时间一览_wow8.0大秘境开启时间介绍_3DM网游...
  11. 【Axure RP8.1】一款专业的快速原型设计工具
  12. 如何下载matlab,如何下载MATLAB?
  13. 联想重装系统去掉保护_带有联想保护系统的电脑安装系统具体步骤如下
  14. typora的安装和使用
  15. 实验二 分析1996~2015年人口数据各个特征的分布与分散状况
  16. 【Ruby on Rails全栈课程】2.1 ruby语言入门
  17. StarCraft II Learning Environment
  18. 2.12用lambda表达式对列表进行排序
  19. NXP JN5168 Zigbee 芯片烧录问题
  20. 关于 vue3.0 实战项目 setup、 props、 reactive、ref

热门文章

  1. memcache单机版安装
  2. geoserver矢量瓦片发服务前端展示偏移问题解决
  3. Suse系统用户不能登录报错
  4. opengl 关于glewGetContext没有定义
  5. Java技巧:提高J2SE性能的代码技巧
  6. 微信公众嵌套页面里再嵌入其他页面的一些问题
  7. jQuery——入门(三)JQuery DOM操作(核心处理和文档处理)
  8. 如何确定图片名未改变 php,这里未改变的是数据库中默认的数据,比如修改时间?,还有发布用户名?...
  9. 7-35 部落 (10 分)
  10. mysql中订单产品名,Ecshop后台订单列表增加”商品名”检索字段