我正在尝试在Apache下启动WSGi应用程序,我有一个奇怪的问题: 当我使用* .py格式的python文件时,一切看起来都很好,但是当我使用* .pyo格式的相同文件(根本没有* .py)时,我在Apache日志文件中有以下消息:
mod_wsgi (pid=27595): Target WSGI script '/usr/local/nb/wwwroot/wsgi_test/main.wsgi' cannot be loaded as Python module.
mod_wsgi (pid=27595): Exception occurred processing WSGI script '/usr/local/nb/wwwroot/wsgi_test/main.wsgi'.
Traceback (most recent call last):
File "/usr/local/nb/wwwroot/wsgi_test/main.wsgi", line 11, in ?
import service_env
ImportError: No module named service_env
Apache版本:Apache / 2.0.63 Python版本:Python 2.4 WSGI版本:3.3 系统:Red Hat Enterprise Linux Server 5.5版
这是我的apache conf-file:
WSGIPythonOptimize 2
<VirtualHost *:80>
DocumentRoot /usr/local/nb/wwwroot/wsgi_test
ErrorLog /var/log/apache/service4supl-errors.log
CustomLog /var/log/apache/service4supl-custom.log combine
<Directory /usr/local/nb/wwwroot/wsgi_test>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /test /usr/local/nb/wwwroot/wsgi_test/main.wsgi
</VirtualHost>