【问题标题】:How to fix " Timeout when reading response headers from daemon process" error when using WSGI with Django and Apache如何在将 WSGI 与 Django 和 Apache 一起使用时修复“从守护进程读取响应标头时超时”错误
【发布时间】:2019-07-30 09:36:14
【问题描述】:

我已经安装了 Django 并使用以下命令创建了一个新项目:

mkdir trydjango
cd trydjango
virtualenv -p python3 .
source bin/activate
pip install django==2.0.7

当我运行pip freeze 时,我看到以下内容:

Django==2.0.7
pkg-resources==0.0.0
pytz==2018.9

在我的虚拟主机中,我有以下内容:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName django.mydomain.com
    ServerAlias www.django.mydomain.com
    DocumentRoot /var/www/django.mydomain.com
    ErrorLog ${APACHE_LOG_DIR}/django.mydomain.com.error.log
    CustomLog ${APACHE_LOG_DIR}/django.mydomain.com.access.log combined


    <Directory root/Dev/trydjango/src/trydjango>
           <Files wsgi.py>
                 Require all granted
           </Files>
        </Directory>

    WSGIApplicationGroup %{GLOBAL}
    WSGIDaemonProcess trydjango python-home=root/Dev/trydjango/bin python-path=root/Dev/trydjango/
    WSGIProcessGroup trydjango
    WSGIScriptAlias / /root/Dev/trydjango/src/trydjango/wsgi.py

</VirtualHost>

但是当我尝试访问我的域时,它会超时。 当我访问域的 Apache 错误日志时,出现以下错误消息:

[pid 12746] [client xx.xx.xx.xxx:60684] 读取响应超时 来自守护进程“trydjango”的标头: /root/Dev/trydjango/src/trydjango/wsgi.py

如何解决这个超时问题?

我已将 wsgi.py 改成 www-data:www-data 我还将应用所在的文件夹设为可执行文件

不确定该全新项目还可以尝试什么来使 wsgi 正常工作。

我发现了这个:Django Webfaction 'Timeout when reading response headers from daemon process'

并将WSGIApplicationGroup %{GLOBAL} 添加到虚拟主机和apache2.conf,但这并没有解决问题。

【问题讨论】:

  • 问题解决了吗?

标签: python django apache wsgi


【解决方案1】:

我只是解决了这样的问题,但是 widht flask-wsgi,我认为是相同的“从守护进程读取响应标头时超时”, 只需转到文件夹“/etc/httpd/conf.d/”(在centos中),在python-wsgi的配置文件中,在我的例子中是“python-wsgi.conf”,

听5002

ServerAdmin webmaster@localhost
#DocumentRoot /var/www/html
DocumentRoot /home/XXXXXXx/XXXXXXXXX
ServerAlias XXXXXXXXXXXXXX
ServerName XXXXXXXXXXXXXXX

LogLevel debug

WSGIDaemonProcess xxxxxxxxxxxxxxxxx python-path=/home/XXXXX/XXXXXXXXXX:/home/XXXXXX/XXXXXXXXX/venv/lib/python3.6/site-packages
WSGIProcessGroup XXXXXXXXXXXXXXX
WSGIScriptAlias / /home/XXXXX/XXXXXXXXXXXXX/app.wsgi 
WSGIPassAuthorization On
WSGIChunkedRequest On
ErrorLog logs/error-5000-dev.log
CustomLog logs/access-5000-dev.log combined

<Directory /home/XXXXX/XXXXXXXXXXXXXXX>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/XXXXXX.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxxxx.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/xxxxxxxxx.com/chain.pem
SetEnv nokeepalive ssl-unclean-shutdown
TimeOut 18000

看,我在文件的最后放置了一个设置属性“TimeOut”,我为测试 18000 放置了大量的秒,并且对我有用,当然,你必须重新启动服务 apache,"service httpd restart “改变之后。默认为 60 秒,如果您不触摸它。试试那个,告诉我你是否解决了问题。祝你好运!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-12
    • 2020-01-16
    • 2023-02-05
    • 2019-01-31
    • 1970-01-01
    • 2021-02-18
    • 2017-04-01
    • 2018-10-15
    相关资源
    最近更新 更多