uWSGI 配置错误 'core/socket.c' - w/ Django & NGINX
uWSGI config error 'core/socket.c' - w/ Django & NGINX
我正在使用 NGINX 和 uWSGI 在 Ubuntu 14.04(Digital Ocean Droplet)上建立一个 Django 站点(紧随其后 tutorial w/ out making a second project)。我可以 运行 我的 Django 站点 manage.py。我也可以 运行 uwsgi --http :8080 --home /home/andrew/Env/personalsitevenv --chdir /home/andrew/andrew-django-personal-site/personalsite -w personalsite.wsgi
没有任何问题。我可以在 IP:Port 上看到我的站点 运行ning。我也可以 运行 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
}
我正在使用 NGINX 和 uWSGI 在 Ubuntu 14.04(Digital Ocean Droplet)上建立一个 Django 站点(紧随其后 tutorial w/ out making a second project)。我可以 运行 我的 Django 站点 manage.py。我也可以 运行 uwsgi --http :8080 --home /home/andrew/Env/personalsitevenv --chdir /home/andrew/andrew-django-personal-site/personalsite -w personalsite.wsgi
没有任何问题。我可以在 IP:Port 上看到我的站点 运行ning。我也可以 运行 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
}