Gunicorn因203 / EXEC而失败

时间:2019-11-26 10:24:24

标签: django linux nginx centos gunicorn

我正在尝试在CentOS 8上部署django项目,并遵循本手册https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7

我的项目文件夹是

/home/xmahop/support_cabinet/support_cabinet/manage.py

virtualenv文件夹是    / home / xmahop / support_cabinet / venv /

etc / systemd / system / gunicorn.service文件是

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

[Service]
User=xmahop
Group=nginx
WorkingDirectory=/home/xmahop/support_cabinet/support_cabinet
ExecStart=/home/xmahop/support_cabinet/venv/bin/gunicorn --workers 3 --bind unix:/home/xmahop/support_cabinet/support_cabinet/support_cabinet/support_cabinet.sock support_cabinet.wsgi:application
[Install]
WantedBy=multi-user.target

nginx conf:

server {
listen 80;
server_name 192.168.136.131;

location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/xmahop/support_cabinet;
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:/home/xmahop/support_cabinet/support_cabinet.sock;
}
}

独角兽状态:

   Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2019-11-26 12:36:20 MSK; 33s ago
  Process: 9188 ExecStart=/home/xmahop/support_cabinet/venv/bin/gunicorn --workers 3 --bind unix:/home/xmahop/support_cabinet/support_cabinet/support_cabinet/support_cabinet.sock support_cabinet.wsgi:application (code=exited, status=>
 Main PID: 9188 (code=exited, status=203/EXEC)

Nov 26 12:36:20 localhost.localdomain systemd[1]: Started gunicorn daemon.
Nov 26 12:36:20 localhost.localdomain systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Nov 26 12:36:20 localhost.localdomain systemd[1]: gunicorn.service: Failed with result 'exit-code'.

Nginx日志为空。

我尝试用chown xmahop:nginx投影项目文件夹和gunicorn conf文件

1 个答案:

答案 0 :(得分:-1)

原因是在SELinux中,他阻止了访问,所以我只是关闭了它,然后它起作用了。