首页 > 解决方案 > 即使在将 WSGIApplication 组设置为 Global 之后,从守护进程读取响应标头时也会超时

问题描述

我正在使用 Apache 在本地托管一个基于 Django 的网页。但是,我收到以下错误:

从守护进程“office”读取响应头时超时:var/www/office/office/wsgi.py。

我尝试将 WSGIApplicationGroup %{GLOBAL} 行添加到 conf 文件中,但仍然出现相同的错误。

这是我的 .conf 文件。

WSGIPythonPath /var/www/office

ServerName office.org
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
WSGIApplicationGroup %{GLOBAL}

<VirtualHost 0.0.0.0:80>


ServerAlias www.office.org

DocumentRoot /var/www/example.com/public_html

<Directory /var/www/example.com>
Require all granted
</Directory>
<Directory /var/www/office/office>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess office python-home=/var/www/venv python-path=/var/www/office
WSGIProcessGroup office
WSGIScriptAlias /verify /var/www/office/office/wsgi.py process-group=office



ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/custom.log combined
</VirtualHost>

这是 wsgi.py 文件:

"""

WSGI config for office project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
"""

import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "office.settings")
application = get_wsgi_application()

标签: djangomod-wsgi

解决方案


我遇到了同样的问题,经过很多努力和尝试不同的事情,本教程帮助我解决了这些问题。

我创建并成功运行了演示项目。对我来说,问题是配置文件中的路径以及使用服务器 python 版本而不是为项目创建虚拟环境。

我希望它会帮助你


推荐阅读