vcc (vcc@163.com) Last update: 2007-12-08
1.Download and install fastcgi for IIS follow http://www.iis.net/default.aspx?tabid=1000051.
2.Download libfcgi.dll source from www.fastcgi.com, compiled python-fastcgi py2.5 for python2.5 python-fastcgi py2.4 for python2.4, or you can download the source from http://cheeseshop.python.org/pypi/python-fastcgi and make it by yourself.
3.Copy libfcgi.dll to \Python25\DLLs, and install python-fastcgi.
4.Copy python.exe in \Python25 to \Python25\DLLs, otherwise the python.exe can’t startup.
5.Add python fastcgi map: Open a command line window, change the current directory to %WINDIR%\system32\inetsrv, run:
cscript fcgiconfig.js -add -section:"PYTHON" -extension:py -path:"C:\\Python25\\DLLs\\python.exe"
6.Create folder c:/inetpub/python.egg directory for python egg cache. Make a startup files django_fastcgi.py in folder \inetpub\ like follow:
#!c:/python25/python.exe
import sys, os
sys.path.insert(0, "c:/XXX") # your django project folder
os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"
os.environ['PYTHON_EGG_CACHE'] = "c:/inetpub/Python.EGG"
import fastcgi
from django.core.handlers.wsgi import WSGIHandler
def django_app(environ, start_response):
handler = WSGIHandler()
return handler(environ, start_response)
s = fastcgi.ThreadedWSGIServer(django_app, workers=5)
s.serve_forever()
7.Open %WINDIR%\system32\inetsrv\fcgiext.ini, modify the [PYTHON] section as follow:
[PYTHON] ExePath=C:\python25\DLLs\python.exe Arguments="c:/inetpub/django_fastcgi.py" QueueLength=999 MaxInstances=20 InstanceMaxRequests=500 RequestTimeout=500 ActivityTimeout=900
8.Just make a empty index.py file in your website folder, and restart your IIS and vist http://localhost/index.py to test it. (if you get 404 error maybe need restart your server.)
Write by vcc