【发布时间】:2018-10-02 06:08:15
【问题描述】:
我正在尝试为我的网络服务器设置 gunicorn,我目前正在学习本教程:https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-a-gunicorn-systemd-service-file
问题是gunicorn没有在我的项目目录下生成myproject.sock文件。
我在这个文件中的配置:/etc/systemd/system/gunicorn.service,看起来像这样:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=daniel
Group=www-data
WorkingDirectory=/home/daniel/myproject
ExecStart=/home/daniel/myproject/myproject_venv/bin/python3 home/daniel/myproject/myproject_venv/bin/gunicorn --workers 3 -b :8000 myproject.wsgi:application
[Install]
WantedBy=multi-user.target
我正在使用来自 Digital Ocean 的 Django 作为我的 Web 服务器,所以一开始,服务器就带有文件和目录,例如 django/django_project/django_project。
但是我没有使用已经制作的文件,而是使用新目录创建了一个新项目(正如教程所说)。
查看 gunicorn 错误日志时,顶部带有 sudo journalctl -u gunicorn,它说:
Listening at: unix:/home/django/gunicorn.socket (1915)
如上所述,我创建了一个新项目,其目录与 django 的目录不同,因此我正在寻找一种方法来更改 gunicorn 正在听的位置。具体来说,我希望它在home/daniel/myproject/myproject.sock 收听。
很遗憾,myproject.sock 由于某种原因不存在。
我的项目文件归 sudo 用户和组所有,因此 unicorn 可以访问。 工作目录应该是正确的。
感谢任何帮助,因为我对 nginx、unicorn 和 django 非常陌生。
【问题讨论】:
标签: django nginx gunicorn digital-ocean