gpt4 book ai didi

django - uWSGI 配置错误 'core/socket.c' - w/Django & NGINX

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:03 24 4
gpt4 key购买 nike

我正在使用 NGINX 和 uWSGI 在 Ubuntu 14.04(Digital Ocean Droplet)上建立一个 Django 站点(在这个 tutorial 之后制作第二个项目)。我可以使用 manage.py 运行我的 Django 站点。我还可以运行 uwsgi --http :8080 --home/home/andrew/Env/personalsitevenv --chdir/home/andrew/andrew-django-personal-site/personalsite -w personalsite.wsgi没有任何问题。我可以看到我的站点在我的 IP:Port 上运行。我也可以毫无问题地运行 uwsgi --http :8000 --module personalsite.wsgi --virtualenv/home/andrew/Env/personalsitevenv

当我转到服务器的 IP 时,我看到的只是 Welcome to nginx! 页面。没有任何 NGINX 日志错误 & sudo service nginx configtest 是干净的。我得到的唯一信息是我为 uWSGI 设置的日志文件,其中包含:

*** Starting uWSGI 2.0.12 (64bit) on [Fri Jul  8 00:41:22 2016] ***
compiled with version: 4.8.4 on 05 July 2016 17:45:39
os: Linux-4.4.0-28-generic #47~14.04.1-Ubuntu SMP Fri Jun 24 16:30:35 UTC 2016
nodename: **********
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /etc/uwsgi/sites
detected binary path: /usr/local/bin/uwsgi
chdir() to /home/andrew/andrew-django-personal-site/personalsite
your processes number limit is 1832
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): No such file or directory [core/socket.c line 230]

任何人都可以在这里发现任何配置问题或任何其他可能出错的地方吗?


/etc/uwsgi/sites/personalsite.ini

[uwsgi]
logto = /var/log/uwsgi/log.txt

project = personalsite
base = /home/andrew
repo = andrew-django-personal-site

chdir = %(base)/%(repo)/%(project)
home = %(base)/Env/personalsitevenv
module = %(project).wsgi:application

master = true
processes = 5

socket = $(base)/%(repo)/%(project)/%(project).sock
chmod-socket = 664
chown-socket = www-data
vacuum = true

/etc/init/uwsgi.conf

description "uWSGI application server in Emperor mode"

start on runlevel [2345]
stop on runlevel [!2345]

setuid andrew
setgid www-data

exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites

/etc/nginx/sites-available/personalsite

server {
listen 80;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/andrew/andrew-django-personal-site/personalsite;
}

location / {
include uwsgi_params;
uwsgi_pass unix:/home/andrew/andrew-django-personal-site/personalsite/personalsite.sock;
}
}

最佳答案

似乎 personalsite.ini 文件包含作为模式的套接字路径,可能有 0 个或多个匹配项,可能与真实路径不匹配,因此将其更新为绝对路径将解决问题。

在您的 personalsite.ini 中:如果你更换

socket = $(base)/%(repo)/%(project)/%(project).sock

用你的套接字位置的绝对路径

socket = /home/andrew/andrew-django-personal-site/personalsite/personalsite.sock

这将解决问题。

一旦您知道套接字位置,您就可以设计一个与其匹配的模式。

nginx 配置中的示例位置:

location / {
uwsgi_pass unix:/home/andrew/andrew-django-personal-site/personalsite/personalsite.sock;
include /your_location/conf/uwsgi_params; // or your own
uwsgi_modifier1 30; // ignore extra if not used
proxy_set_header HTTP_AUTHORIZATION $http_authorization; // only use if needed
proxy_set_header X-Real-IP $remote_addr; // only use if needed
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;// only if needed
proxy_set_header Host $http_host; // only use if needed
proxy_redirect off; // only use if needed
}

关于django - uWSGI 配置错误 'core/socket.c' - w/Django & NGINX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38259187/

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