在mod_wsgi中导入python模块时出错

我们正试图摆脱mod_wsgi上的wsgi应用程序。 在使用wsgiref.simple_server作为debugging环境之前,我们已经运行了它。 现在,我们想把它转移到使用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失败。

我怀疑这与必须设置某种环境variables,但我已经添加/var/www/python到主要应用程序方法上的sys.path ,它不起作用。 任何帮助或指针与此将非常感激。

谢谢!