没有模块名称 django.core.wsgi apache2+ubuntu+mod_wsgi.



>我已经设置了我的wsgipythonpath和守护进程,但错误日志显示上述错误,没有名为django.core.wsgi的模块,我正在分享我的conf,可能是什么错误,以及我如何检查Apache是否可以访问我的django安装。我可以在本地系统上使用相同的配置托管,但不能在远程服务器上托管

WSGIPythonPath /home/env_mysite/lib/python2.7/site-packages
<VirtualHost *:80>
ServerName  localhost
DocumentRoot /home/unixadmin/PBpy
WSGIScriptAlias / /home/unixadmin/PBpy/PBpy/wsgi.py
WSGIDaemonProcess PBpy python-path=/home/env_mysite/lib/python2.7/site-packages
ErrorLog /home/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/unixadmin/PBpy">
Require all granted
</Directory>

试试这个WSGIDaemonProcess

WSGIDaemonProcess <env> python-path=<path to project code> python-home=<path to env>

希望这是有帮助的。

关于mod_wsgi配置,有两件事很突出。

1 - 您使用WSGIDaemonProcess但不使用WSGIProcessGroupapplication-group选项来WSGIScriptAlias,以委派 WSGI 应用程序在守护进程组中运行。

2 - 您不使用推荐的方法来设置 Python 虚拟环境mod_wsgi。看:

  • http://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html

由于您尝试使用Python虚拟环境,另一个可能的问题是您的mod_wsgi是否针对Python 2.7进行了编译,特别是相同的Python安装。您的 Python 虚拟环境是否在同一目标系统上使用 Python 2.7 系统安装创建?

其他奇怪的事情或问题来源是:

1 -ServerName不应设置为localhost。只有当这恰好是Apache发现的第一个VirtualHost时,事情才会起作用。

2 - 用户通常无法访问主目录,因为您的代码在 Apache 下运行,因此它甚至可能无法看到 Python 包。

相关内容

最新更新