django - 即使在将 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()
解决方案
我遇到了同样的问题,经过很多努力和尝试不同的事情,本教程帮助我解决了这些问题。
我创建并成功运行了演示项目。对我来说,问题是配置文件中的路径以及使用服务器 python 版本而不是为项目创建虚拟环境。
我希望它会帮助你
推荐阅读
- python - 我如何从 dict 值和元组列表中获取每个元素并从中生成一个元组
- python - 为什么这个查找无序列表的最小值和最大值的函数在某些情况下不起作用?
- version-control - VCS 窗口中缺少“忽略”选项
- angular-material-stepper - 如何在单击“下一步”时拨打电话并决定是否继续使用 CDKStepper?
- python - 在列中搜索 str 并创建新的项目列表
- ruby-on-rails - 如何根据数据库中的记录创建具有最少位数的 url 链接缩短 slug
- python-3.x - 从列表中删除一定百分比的元素,同时保留列表的结构完整性
- ant - ant如何检查驱动器D是否存在
- python - 在熊猫中编写文件比较
- c - **(x+i) 和 *(*x+i) 之间的区别