uWSGIconfiguration错误'core / socket.c' – w / Django&NGINX

我正在使用NGINX&uWSGI在Ubuntu 14.04(Digital Ocean Droplet)上build立一个Django站点(下面的这个教程没有做第二个项目)。 我可以用manage.py运行我的Django站点。 我也可以运行uwsgi --http :8080 --home /home/andrew/Env/personalsitevenv --chdir /home/andrew/andrew-django-personal-site/personalsite -w personalsite.wsgi没有任何问题。 我可以看到我的网站在我的IP:端口上运行。 我也可以运行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] 

任何人都可以发现任何configuration问题或其他任何可能是错误的吗?


/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的/网站可用/ 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 }