[error] [client X.X.X.X] OSError: [Errno 0] Error
[notice] Parent: child process exited with status 3221225477 -- Restarting.
这个状态号 3221225477 基本没什么意义,再加上 OSError 0 ,这个异常日志让人很无奈。甚至在 Windows 平台下,Apache 最恶劣情况下竟然会弹出一个崩溃错误框,此时事件日志会报告:
cation Popup:0:29722:26:EVENTLOG_INFORMATION_TYPE:弹出应用程序: Microsoft Visual C++ Runtime Library: Runtime Error!
Program: C:\Apache2.2\bin\httpd.exe
This application has requested the Runtime to terminate it in an unusual way.
WSGIScriptAlias 的定义参见 modwsgi wiki ,主要是映射一个URL到一个文件系统地址并委派目标文件为WSGI Script。
赋予本地wsgi文件夹Allow from all权限,是因为这样才能执行WSGI Script。
5、建立wsgi script
在你的web site django总目录下新建一个文件夹wsgi。
在 wsgi 文件夹下新建一个文件 yourproject.wsgi ,内容如下所示:
# complete_project.wsgi is configured to live in projects/complete_project/deploy.
# If you move this file you need to reconfigure the paths below.
import os
import sys
# redirect sys.stdout to sys.stderr for bad libraries like geopy that uses
# print statements for optional import exceptions.
sys.stdout = sys.stderr
from os.path import abspath, dirname, join
from site import addsitedir
from django.core.handlers.wsgi import WSGIHandler
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
sys.path.insert(0, abspath(join(dirname(__file__), ". . /. . /")))
os.environ["DJANGO_SETTINGS_MODULE"] = "yourprojectname.settings_yourproject" #你的settings module名
application = WSGIHandler()
6、重启Aapche即可。
参考资源:
1、mod_wsgi / mod_python ;
2、Performance Estimates for mod_wsgi ;
3、How to use django with mod_wsgi 。
郑昀@玩聚SR 20090810