uWSGI + Nginx(权限被拒绝)+ CentOS

问题描述 投票:0回答:1

我正在尝试使用uwsgi和nginx服务器安装flask应用程序。每次运行服务时,我都会不断收到拒绝权限错误。

/ home / zerotouch / zerotouch / zerotouch.ini

[uwsgi]
module = wsgi

master = true
processes = 5

uid=nginx
gid=nginx
socket = /run/uwsgi/zerotouch.sock
chown-socket = zerotouch:nginx
chmod-socket = 660
vacuum = true

die-on-term = true

/ etc / systemd / system / zerotouch.service

[Unit]
Description=uWSGI instance to serve zerotouch
After=network.target

[Service]
User=zerotouch
Group=nginx

WorkingDirectory=/home/zerotouch/zerotouch

Environment="PATH=/home/zerotouch/zerotouch/env/bin"

ExecStartPre=-/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown zerotouch:nginx /run/uwsgi; chown zerotouch:nginx /home/zerotouch/zerotouch/env/bin/activate;'

ExecStart=/usr/bin/bash -c 'source /home/zerotouch/zerotouch/env/bin/activate;/home/zerotouch/zerotouch/env/bin/uwsgi --ini /home/zerotouch/zerotouch/zerotouch.ini'

[Install]
WantedBy=multi-user.target

错误

 systemctl status zerotouch
● zerotouch.service - uWSGI instance to serve zerotouch
   Loaded: loaded (/etc/systemd/system/zerotouch.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-10-10 16:34:35 CEST; 8s ago
  Process: 28843 ExecStart=/usr/bin/bash -c source /home/zerotouch/zerotouch/env/bin/activate;/home/zerotouch/zerotouch/env/bin/uwsgi --ini /home/zerotouch/zerotouch/zerotouch.ini (code=exited, status=1/FAILURE)
  Process: 28839 ExecStartPre=/usr/bin/bash -c mkdir -p /run/uwsgi; chown zerotouch:nginx /run/uwsgi; chown zerotouch:nginx /home/zerotouch/zerotouch/env/bin/activate; (code=exited, status=127)
 Main PID: 28843 (code=exited, status=1/FAILURE)

Oct 10 16:34:35 aj-poc-1 bash[28843]: detected binary path: /home/zerotouch/zerotouch/env/bin/uwsgi
Oct 10 16:34:35 aj-poc-1 bash[28843]: your processes number limit is 7259
Oct 10 16:34:35 aj-poc-1 bash[28843]: your memory page size is 4096 bytes
Oct 10 16:34:35 aj-poc-1 bash[28843]: detected max file descriptor number: 1024
Oct 10 16:34:35 aj-poc-1 bash[28843]: lock engine: pthread robust mutexes
Oct 10 16:34:35 aj-poc-1 bash[28843]: thunder lock: disabled (you can enable it with --thunder-lock)
Oct 10 16:34:35 faj-poc-1 bash[28843]: bind(): Permission denied [core/socket.c line 230]
Oct 10 16:34:35 aj-poc-1 systemd[1]: zerotouch.service: main process exited, code=exited, status=1/FAILURE
Oct 10 16:34:35 aj-poc-1 systemd[1]: Unit zerotouch.service entered failed state.
Oct 10 16:34:35 aj-poc-1 systemd[1]: zerotouch.service failed.

nginx centos7 uwsgi
1个回答
0
投票

创建和编辑套接字的权限存在问题。

所以我去了/ run / uwsgi并使用ls -lhtr来获得文件权限的概述

然后我使用vi zerotouch.sock创建了一个空白的袜子文件zerotouch.sock

并且为该文件添加了对用户:zerotouch和组:nginx的权限

 chown zerotouch:nginx -R /run/uwsgi
© www.soinside.com 2019 - 2024. All rights reserved.