mod_wsgi无法解析WSGI脚本文件处理WSGI脚本时发生异常|无法导入“网站”模块

时间:2017-06-02 10:04:44

标签: python django apache centos mod-wsgi

我在一台centos 6.9机器上使用httpd与mod_wsgi和httpd在这里是相关的文件,我试图在apache 2.15版本上部署django,triend谷歌很多但无法解决问题,任何帮助将不胜感激< / p>

django.conf

WSGIPythonHome /home/pbadmin/venv/bin/python
WSGIPythonPath /home/pbadmin/venv/lib/python2.7/site-packages


<VirtualHost *:8888>

   ServerAdmin root@localhost
   ServerName  10.0.48.40
   DocumentRoot /var/www/PBpy
   WSGIScriptAlias / /var/www/PBpy/PBpy/wsgi.py

   WSGIDaemonProcess PBpy python-path=/home/pbadmin/venv/lib/python2.7/site-packages


   ErrorLog "/home/pbadmin/pylogs"
   <Directory "/var/www/PBpy">
     Order deny,allow
     Allow from all
   </Directory>

</VirtualHost>

wsgi.py

import os
import sys

#sys.path.append('/var/www/PBpy')

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "PBpy.settings")

application = get_wsgi_application()

错误日志

[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94] mod_wsgi (pid=6148): Target WSGI script '/home/pbadmin/PBpy/apache/django.wsgi' cannot b$
[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94] mod_wsgi (pid=6148): Exception occurred processing WSGI script '/home/pbadmin/PBpy/apach$
[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94] Traceback (most recent call last):
[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94]   File "/home/pbadmin/PBpy/apache/django.wsgi", line 10, in <module>
[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94]     import django.core.handlers.wsgi
[Thu Jun 01 12:27:24 2017] [error] [client 10.0.32.94]   File "/home/pbadmin/venv/lib/python2.7/site-packages/django/__init__.py", line 3, in <

1 个答案:

答案 0 :(得分:0)

您不应该为WSGIPythonHome的{​​{1}}设置python作为开始。读:

如何正确设置Python虚拟环境。

您还缺少WSGIProcessGroup指令。您实际上并未将应用程序委派给已定义的守护程序进程组。