Gar*_*ary 5 python apache django wsgi
我已经安装了Django并使用以下命令创建了一个新项目:
mkdir trydjango
cd trydjango
virtualenv -p python3 .
source bin/activate
pip install django==2.0.7
Run Code Online (Sandbox Code Playgroud)
运行时pip freeze
,我看到以下内容:
Django==2.0.7
pkg-resources==0.0.0
pytz==2018.9
Run Code Online (Sandbox Code Playgroud)
在我的虚拟主机中,我有以下内容:
<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>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试访问我的域时,它超时了。当我访问该域的Apache错误日志时,出现以下错误消息:
[pid 12746] [客户端xx.xx.xx.xxx:60684]从守护进程“ trydjango”读取响应头时超时:/root/Dev/trydjango/src/trydjango/wsgi.py
如何解决此超时问题?
我将wsgi.py更改为www-data:www-data,并且将应用程序设置为可执行文件夹
不知道还有什么可以尝试使用此全新项目来使wsgi正常工作。
我发现了这一点:Django Webfaction'从守护进程读取响应头时超时'
并添加WSGIApplicationGroup %{GLOBAL}
到virtualhost以及apache2.conf中,但这不能解决问题。
我只是解决了这样的问题,但是对于flask-wsgi,我认为是相同的“从守护进程读取响应头时超时”,只需转到文件夹“/etc/httpd/conf.d/”(在centos中) ,在 python-wsgi 的配置文件中,在我的例子中为“python-wsgi.conf”,
监听 5002 <虚拟主机 192.168.150.62: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
Run Code Online (Sandbox Code Playgroud)
看,我在文件的最后放置了一个设置属性“TimeOut”,我在测试18000时放置了大量的秒数,并且对我有用,当然,您必须重新启动服务apache,“service httpd restart”之后改变。如果你不碰它,默认是60秒。尝试一下,然后告诉我你是否解决了问题。祝你好运。!
归档时间: |
|
查看次数: |
508 次 |
最近记录: |