如何解决以低特权用户身份启动Uwsgi
我有一台运行Django,uwsgi和nginx的服务器。我无法以非root用户身份启动uwsgi。我确实以root身份启动了它,并且可以正常工作。 我遵循了here和here的说明,但是我无法在ini(/tmp/blog.sock)中指定的位置找到套接字文件,也无法更改权限。
我的uwsgi.ini:
[uwsgi]
# variables
projectname = blog
base = /var/www/blog
# configuration
master = true
virtualenv = /root/.virtualenvs/blog
pythonpath = %(base)
chdir = %(base)
env = DJANGO_SETTINGS_MODULE=%(projectname).settings.pro
module = %(projectname).wsgi:application
socket = /tmp/%(projectname).sock
chmod-socket = 666
drwxrwxrwx 2 root root 4096 Aug 11 12:37 .
drwxrwxrwx 13 root root 4096 Aug 11 09:57 ..
-rw-r--r-- 1 root root 643 Aug 11 11:18 nginx.conf
-rw-r--r-- 1 root root 535 Aug 11 12:34 nginx.conf.save
-rw-r--r-- 1 root root 317 Aug 10 19:40 uwsgi.ini
非根尝试:
root@localhost:/var/www/blog# uwsgi --ini config/uwsgi.ini --uid www-data
[uWSGI] getting INI configuration from config/uwsgi.ini
*** Starting uWSGI 2.0.19.1 (64bit) on [Tue Aug 11 12:29:19 2020] ***
compiled with version: 7.5.0 on 10 August 2020 19:38:17
os: Linux-4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020
nodename: localhost
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /var/www/blog
detected binary path: /usr/local/bin/uwsgi
setuid() to 33
chdir() to /var/www/blog
your processes number limit is 3693
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)
error removing unix socket,unlink(): Operation not permitted [core/socket.c line 198]
bind(): Address already in use [core/socket.c line 230]
具有根:
root@localhost:/var/www/blog# uwsgi --ini config/uwsgi.ini
[uWSGI] getting INI configuration from config/uwsgi.ini
*** Starting uWSGI 2.0.19.1 (64bit) on [Tue Aug 11 12:29:27 2020] ***
compiled with version: 7.5.0 on 10 August 2020 19:38:17
os: Linux-4.15.0-101-generic #102-Ubuntu SMP Mon May 11 10:07:26 UTC 2020
nodename: localhost
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /var/www/blog
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root,you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /var/www/blog
your processes number limit is 3693
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)
uwsgi socket 0 bound to UNIX address /tmp/blog.sock fd 3
uWSGI running as root,you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.6.9 (default,Jul 17 2020,12:50:27) [GCC 8.4.0]
PEP 405 virtualenv detected: /root/.virtualenvs/blog
Set PythonHome to /root/.virtualenvs/blog
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x555e5b137bc0
uWSGI running as root,you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145808 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
added /var/www/blog/ to pythonpath.
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x555e5b137bc0 pid: 28259 (default app)
uWSGI running as root,you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 28259)
spawned uWSGI worker 1 (pid: 28261,cores: 1)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。