我刚刚完成了 mod_wsgi 的安装,但我在启动 Pyramid 应用程序时遇到了问题。
我在 CentOS 5.8 上使用 python 2.7、Apache 2.2.3、mod_wsgi 3.4
这是我的 httpd.config 文件
WSGISocketPrefix run/wsgi
<VirtualHost *:80>
ServerName myapp.domain.com
ServerAlias myapp
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid user=apache group=apache processes=1 threads=4 \
python-path=/var/wsgi_sites/site-packages
WSGIScriptAlias / /var/wsgi_sites/myapp/apache.wsgi
<Directory /var/wsgi_sites/myapp>
WSGIProcessGroup pyramid
Order allow,deny
Allow from all
</Directory>
LogLevel debug
ErrorLog /var/log/httpd/myapp_error
</VirtualHost>
我已经给了 Apache 对 site-package、python-eggs 和 myapp 文件夹的所有权。
我用来创建 WSGI 应用程序 appache.wsgi 的模块包含以下代码
import os
os.environ['PYTHON_EGG_CACHE'] = '/var/wsgi_sites/python-eggs'
from pyramid.paster import get_app
application = get_app('/var/wsgi_sites/myapp/development.ini','main')
当我重新启动 Apache 并尝试访问应用程序时,我收到以下错误
mod_wsgi (pid=14842, process='pyramid', application=''): Loading WSGI script '/var/wsgi_sites/myapp/apache.wsgi'.
mod_wsgi (pid=14842): Target WSGI script '/var/wsgi_sites/myapp/apache.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=14842): Exception occurred processing WSGI script '/var/wsgi_sites/myapp/apache.wsgi'.
Traceback (most recent call last):
File "/var/wsgi_sites/myapp/apache.wsgi", line 4, in ?
from pyramid.paster import get_app
File "/var/wsgi_sites/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/__init__.py", line 1, in ?
from pyramid.request import Request
File "/var/wsgi_sites/site-packages/pyramid-1.3.2-py2.7.egg/pyramid/request.py", line
class Request(BaseRequest, DeprecatedRequestMethodsMixin, URLMethodsMixin,
^
SyntaxError: invalid syntax
我尝试查看 request.py 文件,但没有语法错误。