【发布时间】:2012-11-05 18:50:11
【问题描述】:
我们正试图让 wsgi 应用程序在 mod_wsgi 上运行。在使用wsgiref.simple_server 作为调试环境之前,我们已经运行了它。现在,我们想把它转移到使用 Apache httpd 来集成在同一端口下加载静态文件,并提供一个更适合生产的环境。
我们设置的 httpd.conf 文件如下所示:
<VirtualHost *:80>
DocumentRoot /var/www/
ErrorLog /var/www/log/error_log
LogLevel debug
WSGIScriptAlias /app /var/www/python/resource/rest.py
<Directory /var/www/python/>
Order allow,deny
Allow from all
</Directory>
<Directory />
Order allow,deny
Allow from all
RewriteEngine On
# Some rewrites go here
</Directory>
</VirtualHost>
通过此设置,我们可以访问主应用程序文件 rest.py(在 http://myhost/app 下),但是任何对模块的导入(如 from module1 import function,其中 module1 与 rest.py 在同一目录下)都失败了ImportError。
我怀疑这与必须设置某种环境变量有关,但我已在主应用程序方法上将 /var/www/python 添加到 sys.path 并且它不起作用。对此的任何帮助或指示将不胜感激。
谢谢!
【问题讨论】: