Rob*_*obo 5 python django nginx gunicorn
当我运行时sudo systemctl status gunicorn,出现以下错误:
\xe2\x97\x8f gunicorn.service - gunicorn daemon\n Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)\n Active: failed (Result: exit-code) since Tue 2022-02-08 07:29:18 UTC; 17min ago\n Main PID: 21841 (code=exited, status=217/USER)\n\nFeb 08 07:29:18 ip-172-31-37-113 systemd[1]: Started gunicorn daemon.\nFeb 08 07:29:18 ip-172-31-37-113 systemd[21841]: gunicorn.service: Failed to determine user credentials: No such process\nFeb 08 07:29:18 ip-172-31-37-113 systemd[21841]: gunicorn.service: Failed at step USER spawning /home/ubuntu/bookclub/venv/bin/gun\nFeb 08 07:29:18 ip-172-31-37-113 systemd[1]: gunicorn.service: Main process exited, code=exited, status=217/USER\nFeb 08 07:29:18 ip-172-31-37-113 systemd[1]: gunicorn.service: Failed with result \'exit-code\'.\nRun Code Online (Sandbox Code Playgroud)\n我正在按照DigitalOcean 的本教程将我的 Django 网站连接到我的 EC2 实例上。我使用 Nginx 和 Gunicorn 以及 Django 来完成此任务。
\n这是我的gunicorn.service文件/etc/systemd/system/gunicorn.service:
[Unit]\nDescription=gunicorn daemon\nAfter=network.target\n\n[Service]\nUser=sammy\nGroup=www-data\nWorkingDirectory=/home/ubuntu/bookclub\nExecStart=/home/ubuntu/bookclub/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/bookclub/books.sock books.wsgi:application\n\n[Install]\nWantedBy=multi-user.target\nRun Code Online (Sandbox Code Playgroud)\nbooks.sock我在我的项目文件夹中检查了ls,发现它books.sock 不存在。
我将UserGunicorn 服务文件从sammy(不存在)更改为ubuntu(服务器上唯一存在的)。
所以我gunicorn.service现在看起来像这样:
[Unit]\nDescription=gunicorn daemon\nAfter=network.target\n\n[Service]\nUser=sammy\nGroup=www-data\nWorkingDirectory=/home/ubuntu/bookclub\nExecStart=/home/ubuntu/bookclub/venv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/bookclub/books.sock books.wsgi:application\n\n[Install]\nWantedBy=multi-user.target\nRun Code Online (Sandbox Code Playgroud)\n但我收到另一个错误:
\n\xe2\x97\x8f gunicorn.service - gunicorn daemon\n Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)\n Active: failed (Result: exit-code) since Tue 2022-02-08 09:23:41 UTC; 19s ago\n Main PID: 22533 (code=exited, status=203/EXEC)\n\nFeb 08 09:23:41 ip-172-31-37-113 systemd[1]: Started gunicorn daemon.\nFeb 08 09:23:41 ip-172-31-37-113 systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC\nFeb 08 09:23:41 ip-172-31-37-113 systemd[1]: gunicorn.service: Failed with result \'exit-code\'.\nRun Code Online (Sandbox Code Playgroud)\n
小智 1
您被误导了,因为在会话开始时需要遵循一个外部过程:初始服务器设置指南。
去做:
创建用户sammy
重要的
usermod -aG sudo sammy
Run Code Online (Sandbox Code Playgroud)
切换到 Sammy 个人资料
在 sammy 配置文件下创建 django 项目
pwd
/home/sammy
Run Code Online (Sandbox Code Playgroud)
一切都会很好
原因 ?1_可能这是数据库用户 2_可能根配置文件无效。天知道。祝你好运。
| 归档时间: |
|
| 查看次数: |
11438 次 |
| 最近记录: |