[大家好,我在这里有点混乱,要使用Gunicorn和Ngnix将Django应用部署到数字海洋。我正在按照我在udemy上购买的视频教程中的步骤进行操作,我们在其中链接https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#disable-root-login。在学习本教程的过程中,一切工作到了我设置gunicorn之前的水平,这意味着我能够通过IP地址看到该网站。但是,只有静态文件不是由Nginx处理的,此时我是在使用python manage.py runserver 0.0.0.0:8000
来运行服务器的。当我执行此步骤并配置gunicorn和Nginx时,使用IP地址访问时得到https://gist.github.com/bradtraversy/cfa565b879ff1458dba08f423cb01d71#run-server。
我想知道为什么会遇到这个问题,并且注意到当我使用502 Bad Gateway
检查gunicorn的状态时,我得到了:
sudo systemctl status gunicorn.socket
这里是我想要添加到服务器的项目的链接,如果需要 gunicorn.socket - gunicorn socket
Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
Active: failed (Result: service-start-limit-hit) since Fri 2020-02-28 03:03:11 UTC; 7s ago
Listen: /run/gunicorn.sock (Stream)
当我运行https://github.com/opeodedeyi/medxFinal时我得到
sudo nginx -t
请我真的需要帮助。
您是否检查了gunicorn.service和gunicorn.socket文件?您是否在gunicorn.service文件中为用户添加了正确的用户名?
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
如果是这样,请尝试以下命令curl --unix-socket /run/gunicorn.sock本地主机如果以上命令在终端中打印出了html页面,那么您可以继续执行此操作,否则请更改gunicorn.service文件,然后重试]
[Service]
User=<yourusername>
Group=www-data