简体   繁体   English

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

[英]mod_wsgi Failed to parse WSGI script file | Exception occurred processing WSGI script | Unable to import 'site' module

I am using httpd with mod_wsgi with httpd on a centos 6.9 machine here are relevant files, I am trying to deploy django on an apache 2.15 version, triend to google a lot but couldnot solve the issue, any help would be appreciated 我在centos 6.9机器上将httpd和mod_wsgi与httpd一起使用,这是相关文件,我正在尝试在apache 2.15版本上部署django,很多人都使用google,但无法解决问题,任何帮助将不胜感激

django.conf 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 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()

error log 错误日志

[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 <

You aren't supposed to be setting WSGIPythonHome to the binary for python for a start. 首先,您不应该将WSGIPythonHome设置为python的二进制文件。 Read: 读:

for how to set up Python virtual environment properly. 有关如何正确设置Python虚拟环境的信息。

You are also missing a WSGIProcessGroup directive. 您还缺少WSGIProcessGroup指令。 You aren't actually delegating the application to the daemon process group to have defined. 您实际上并没有将应用程序委派给已定义的守护进程组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM