我试图得到一个Django + mod_fcgid设置工作(mod_wsgi是棘手的,因为我有一个静态链接的Python。不要问)。虽然这是在我的Mac OS X开发框上微不足道,让它在服务器上运行迄今为止,certificate是不可能的。
有了这个configuration
LoadModule fcgid_module modules/mod_fcgid.so FCGIDSocketPath run/mod_fcgid FCGIDSharememPath run/mod_fcgid/fcgid_shm ScriptAliasMatch /apps/([^/]+)(/.*)? /var/www/apps/$1/apache/dispatch.fcgi$2 <DirectoryMatch ^/var/www/apps/([^/]+)/apache> SetHandler fcgid-script Order allow,deny Allow from all Options +ExecCGI </DirectoryMatch>
和这个例子dispatch.fcgi :
#!/usr/bin/python import sys sys.path.insert(0, '/var/www/lib/python2.5/site-packages/flup-1.0.2.egg') def myapp(environ, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) return ['This is my hello world test!\n'] if __name__ == '__main__': from flup.server.fcgi import WSGIServer WSGIServer(myapp).run()
浏览到我的testing页面会产生一个500错误,在我的Apache错误日志中,我得到:
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI! WSGIServer: missing FastCGI param SERVER_NAME required by WSGI! WSGIServer: missing FastCGI param SERVER_PORT required by WSGI! WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI! Status: 200 OK Content-Type: text/plain Content-Length: 29 This is my hello world test! [Wed Sep 30 11:09:18 2009] [notice] mod_fcgid: process /var/www/apps/test/apache/dispatch.fcgi(31043) exit(server exited), terminated by calling exit(), return code: 0
有我的输出,看起来不错 – 除了在Apache的错误日志,而不是我的浏览器窗口。
当我删除我的SetHandler指令,输出到我想要的地方; 显然,它运行在普通的CGI模式下。 这对我的Django应用程序来说不够高效,因为它在该configuration中获取了1-2秒的页面加载时间。
到目前为止,我已经尝试过:
除了使用AliasMatch显示源代码之外,没有任何区别似乎有什么区别,这是我所期望的。
再说一遍,这在Mac OS X上是微不足道的。它只是在类似的configuration下工作。
除了得到一个更好的Python和使用mod_wsgi(这是可能的,如果痛苦),我该如何使它工作?
问题:一些SELinux政策。 我不够专业来诊断它,但是要做:
/usr/sbin/setenforce 0
使一切工作像一个魅力。