【发布时间】:2016-08-14 21:14:33
【问题描述】:
我正在使用nginx 和gunicorn 在我的django 项目中工作,正如这里所说:
我的网站在本地工作,但是当我启动 nginx 和 gunicorn 服务器时,我有
502 网关错误。
操作系统是UBUNTU 14.04
我正在尝试使我的项目正常运行,并以 root 身份重新安装所有内容(我知道这很糟糕)——同样的错误。
这是我的“error.log”:
2016/04/20 20:15:10 [crit] 10119#0: *1 connect() to
unix:/root/myproject/myproject.sock 失败(13:权限被拒绝) 连接上游时,客户端:46.164.23
当我运行命令“nginx”时:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
我的 gunicorn.conf
description "Gunicorn application server handling myproject"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid root
setgid www-data
chdir /root/myproject
exec myprojectenv/bin/gunicorn --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application
那是我的“/etc/nginx/sites-available/myproject”
server {
listen 80;
server_name www.mysite.ru;
error_log /nginx_error.log;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/myproject;
}
location / {
include proxy_params;
proxy_pass http://unix:/root/myproject/myproject.sock;
}
}
非常感谢您的帮助!!!
【问题讨论】:
标签: python django unix ubuntu nginx