好的,所以我现在已经研究了一段时间了,我知道很多人都有类似的问题,但我似乎找不到合适的解决方案 .

无论如何,我按照数字海洋上的布局完全按照教程进行操作

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

当我测试gunicorn时,一切正常

gunicorn --bind 0.0.0.0:8000 myproject.wsgi:application

但是,当我创建一个systemd文件并尝试使用nginx创建代理传递时,我收到502错误的网关错误 .

当我跑:

sudo tail -f /var/log/nginx/error.log

我收到错误消息:

15:18:39 [crit] 10558#10558: *1 connect() to unix:/home/bmhinformatics/Desktop/ProvCaRe/ProvCaRe.sock failed (2: No such file or directory) while connecting to upstream

我的gunicorn systemd文件看起来像:

/etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/usr/myproject
ExecStart=/home/usr/myproject/myprojectenv/bin/gunicorn --workers 3 --bind    unix:/home/usr/myproject/myproject.sock myproject.wsgi:application

[Install]
WantedBy=multi-user.target

和我的nginx proxypass文件看起来像:

在/ etc / nginx的/网站可用/ myproject的

server {
  listen 80;
  server_name server_domain_or_IP;

  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
      root /home/usr/myproject;
  }

  location / {
      include proxy_params;
      proxy_pass http://unix:/home/sammy/myproject/myproject.sock;
  }
}

我似乎无法识别错误 . 任何帮助表示赞赏 . 谢谢!