请您检查我的代码,并告诉我该错误来自何处?
gunicorn.sevice文件:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=nginx
WorkingDirectory=/root/parsiproject
ExecStart=/root/parsiproject/parsiEnv/bin/gunicorn --workers 3 --bind
unix:/root/parsiproject/myproject.sock myproject.wsgi:applicat$
[Install]
WantedBy=multi-user.target
nginx.conf文件:
...
server {
listen 80;
server_name 64.34.135.108;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /root/parsiproject;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/root/parsiproject/myproject.sock;
}
...
nginx error.log:
2018/08/12 11:57:37 [crit] 3792#0: *35 connect() to
unix:/home/user/myproject/myproject.sock failed (2: No such file or
directory) w$
我已经将服务器IP插入到setting.py允许的主机中。
答案 0 :(得分:0)
我猜您的套接字路径不正确,并且gunicorn服务文件也有问题。我猜myproject.wsgi:applicat$
也应该是myproject.wsgi:application
。请按照下面的教程创建套接字和所有路径。
以下是服务文件的示例:
[Unit]
Description=xyz django daemon
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/var/www/services/xyz_backend/xyz_backend
ExecStart=/var/www/services/xyz_backend/xyz_python_env/bin/gunicorn --access-logfile - --workers 3 --bind unix:/var/www/services/xyz_backend/xyz_backend/xyz.sock xyz_backend.wsgi:application