IIS 사이트 뒤에서 CherryPy를 실행합니다. 작동 시키려면 몇 가지 트릭이 있습니다.
- IIS 작업자 프로세스 ID로 실행하는 경우 사용자 프로세스에서 사이트를 실행할 때와 동일한 사용 권한을 갖지 않습니다. 상황이 깨질 것입니다. 특히, 파일 시스템에 쓰고 자하는 모든 것은 아마도 약간의 조정 없이는 작동하지 않을 것입니다.
- setuptools를 사용하는 경우 구성 요소를 -Z 옵션 (모든 달걀을 압축 해제)과 함께 설치하고자 할 수 있습니다.
- win32traceutil을 사용하여 문제를 추적하십시오. win32traceutil을 가져 오는 후크 스크립트에 있는지 확인하십시오. 그런 다음 웹 사이트에 액세스하려고 할 때 문제가 발생하면 표준 출력으로 인쇄되는지 추적 유틸리티에 기록됩니다. 'python -m win32traceutil'을 사용하여 추적 결과를 확인하십시오.
ISAPI 응용 프로그램을 실행하려면 기본 프로세스를 이해해야합니다. 먼저 ISAPI_WSGI에서 실행되는 안녕하세요 - 세계 WSGI 응용 프로그램을 얻는 것이 좋습니다. 다음은 CherryPy가 내 웹 서버와 함께 작동하는지 확인하는 데 사용한 후크 스크립트의 초기 버전입니다.
#!python
"""
Things to remember:
easy_install munges permissions on zip eggs.
anything that's installed in a user folder (i.e. setup develop) will probably not work.
There may still exist an issue with static files.
"""
import sys
import os
import isapi_wsgi
# change this to '/myapp' to have the site installed to only a virtual
# directory of the site.
site_root = '/'
if hasattr(sys, "isapidllhandle"):
import win32traceutil
appdir = os.path.dirname(__file__)
egg_cache = os.path.join(appdir, 'egg-tmp')
if not os.path.exists(egg_cache):
os.makedirs(egg_cache)
os.environ['PYTHON_EGG_CACHE'] = egg_cache
os.chdir(appdir)
import cherrypy
import traceback
class Root(object):
@cherrypy.expose
def index(self):
return 'Hai Werld'
def setup_application():
print "starting cherrypy application server"
#app_root = os.path.dirname(__file__)
#sys.path.append(app_root)
app = cherrypy.tree.mount(Root(), site_root)
print "successfully set up the application"
return app
def __ExtensionFactory__():
"The entry point for when the ISAPIDLL is triggered"
try:
# import the wsgi app creator
app = setup_application()
return isapi_wsgi.ISAPISimpleHandler(app)
except:
import traceback
traceback.print_exc()
f = open(os.path.join(appdir, 'critical error.txt'), 'w')
traceback.print_exc(file=f)
f.close()
def install_virtual_dir():
import isapi.install
params = isapi.install.ISAPIParameters()
# Setup the virtual directories - this is a list of directories our
# extension uses - in this case only 1.
# Each extension has a "script map" - this is the mapping of ISAPI
# extensions.
sm = [
isapi.install.ScriptMapParams(Extension="*", Flags=0)
]
vd = isapi.install.VirtualDirParameters(
Server="CherryPy Web Server",
Name=site_root,
Description = "CherryPy Application",
ScriptMaps = sm,
ScriptMapUpdate = "end",
)
params.VirtualDirs = [vd]
isapi.install.HandleCommandLine(params)
if __name__=='__main__':
# If run from the command-line, install ourselves.
install_virtual_dir()
이 스크립트는 몇 가지 작업을 수행합니다. ISAPI 핸들러에서 사용하는 CherryPy WSGI 인스턴스를 생성합니다 (setup_application()). IIS가 [ ].
\ inetpub \ cherrypy 디렉터리에이 파일을 저장 한 후 실행하면 "CherryPy Web Server"라는 IIS 웹 사이트의 루트에 자신을 설치하려고 시도합니다.
이 모든 것을 다른 모듈로 리팩터드 한 production web site code을 사용해 주셔서 감사합니다.
cherrypy가 작동 할 때 * 아파치, 아파치와의 충돌을 피하기 위해 다른 포트 (예 : 8080)에 바인드해야 했습니까? 아니면 좀 더 미묘한 것이 었습니까? cherrypy가 독립 실행 형 웹 사이트를 수행 할 수 있고 * 아파치가 필요하지 않기 때문에 요청합니다. – pavium
아파치의 포트 80에 연결했습니다. 독립 실행 형 Cherrypy 호스트가 원하는 경우 80 번 포트 (또는 다른 포트)에서 수신 대기하도록 설정할 수 있습니다. – hsimah
포트 번호는 중요하지 않습니다. ISAPI-wsgi를 사용할 때 WSGI 응용 프로그램은 웹 서버 프로세스 (DLL에 의해로드 됨)에서 기본적으로 호출되므로 관련 포트 번호는 IIS에서 구성된 포트 번호입니다. –