无法以root用户身份运行uwsgi

无法以root用户身份运行uwsgi

本文介绍了无法以root用户身份运行uwsgi,"bind():权限被拒绝"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用此文档配置uWsgi,Django,Nginx: http://uwsgi-docs.readthedocs.org/en/latest/tutorials /Django_and_nginx.html

I try to configure uWsgi, Django ,Nginx with this document:http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html

完成uwsgi.ini文件的配置,在/etc/uwsgi/vassals处创建一个软链接.

Finish config the uwsgi.ini file, create a soft link at /etc/uwsgi/vassals.

在最后一步失败:在系统启动时启动uWSGI .

运行此命令时:

sudo /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data

我收到此错误:

clock source: unix
detected number of CPU cores: 1
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 3813
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Permission denied [core/socket.c line 227]
Tue May 27 05:29:26 2014 - [emperor] curse the uwsgi instance uwsgi.ini (pid: 1391)
Tue May 27 05:29:29 2014 - [emperor] removed uwsgi instance uwsgi.ini

如果我在不使用sudo的情况下运行此命令,一切正常.

If I run this command without sudo, everything is OK.

我已将用户"kk"添加到"www-data"组中,这是uwsgi.ini

I've add user "kk" into group "www-data", and here is the uwsgi.ini

[uwsgi]
chdir           = /home/kk/XXXXXXX
module          = wsgi
home            = /home/kk/XXXXXXX

master          = true
processes       = 10
socket          = /home/kk/XXXXXXX/mysite.sock
chmod-socket    = 666
vacuum          = true

我想也许我在文件许可权上弄错了.有人有个好主意吗?谢谢.

I guess maybe I made mistake on file permission. Does anybody have good idea?Thank you.

更新:

官方文档是正确的,我按照步骤将项目部署到另一个新的VPS中,没有发生错误.

The official document is correct, I follow the steps to deploy the project in another new VPS, no error occurred.

推荐答案

我遇到了这个问题.在不设置组和用户ID的情况下运行可以解决该问题.当我有更多时间修复目录的文件权限时,我可能会重新审视此问题,但是暂时可以使用

I was having this problem. Running without setting the group and user ids solved the problem. I'll probably revisit this when I have more time to fix file permissions for the directory, but it works for the moment

/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals

编辑我有时间重新讨论这个答案,我不得不说,在生产环境中运行uwsgi时,这不是 个好习惯.

EDITI've had time to revisit this answer and I'd have to say that this is not good practice when running uwsgi in production.

本教程编写的问题在于,它假定www-data是用户,并且www-data用户和组有权访问服务器上所需的所有文件;特别是套接字文件.将适当的参数替换为您的用户和组,您会很方便(并且不会在服务器上留下巨大的安全漏洞).

The problem with the tutorial as written is that it assumes that www-data is a user and that the www-data user and group has access to all the files it needs on your server; in particular the socket file. Replace the appropriate arguments with your user and group and and you'll be good to go (and won't leave a gaping security hole on your server).

因此,正确的命令(如果我是组ovangle中的用户ovangle将是):

So, the correct command (if I was user ovangle in group ovangle would be):

/usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid ovangle --gid ovangle

最好创建一个具有成功运行服务器所需的特定权限的用户,但这留给读者练习.

It would be better to create a user which has the specific permissions it needs to run the server successfully, but that's left as an exercise for the reader.

这篇关于无法以root用户身份运行uwsgi,"bind():权限被拒绝"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 03:28