我们正试图摆脱在mod_wsgi上工作的wsgi应用程序。我们在使用wsgiref.simple_server
作为调试环境之前已经运行了它。现在,我们希望将它转移到使用Apache httpd集成在同一端口下加载静态文件,并提供更适合生产的环境。用mod_wsgi导入python模块
我们设立了这个样子的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
,它不起作用。任何帮助或指针与此将非常感激。
谢谢!
重复的http://serverfault.com/questions/445636/error-importing-python-modules-in-mod-wsgi –