gpt4 book ai didi

python - mod_wsgi 解析 WSGI 脚本文件失败 |处理 WSGI 脚本时发生异常 |无法导入 'site' 模块

转载 作者:行者123 更新时间:2023-12-04 19:43:20 28 4
gpt4 key购买 nike

我在 centos 6.9 机器上使用 httpd 和 mod_wsgi 和 httpd 这里是相关文件,我正在尝试在 apache 2.15 版本上部署 django,尝试谷歌但无法解决问题,任何帮助将不胜感激

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 <

最佳答案

你不应该设置 WSGIPythonHomepython 的二进制文件作为一个开始。读:

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

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

    您还缺少 WSGIProcessGroup指示。您实际上并没有将应用程序委托(delegate)给已定义的守护进程组。

    关于python - mod_wsgi 解析 WSGI 脚本文件失败 |处理 WSGI 脚本时发生异常 |无法导入 'site' 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44326227/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com