设置django以使用uwsgi我可以使用virtualenv之外的命令uwsgi --ini kb_uwsgi.ini --http :8000
来运行它但是尝试运行emperor命令sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
会带来错误:
ubuntu@ip-172-31-16-133:/etc/uwsgi/vassals$ ls
kb_uwsgi.ini
ubuntu@ip-172-31-16-133:/etc/uwsgi/vassals$ sudo uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data
*** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:11 2017] ***
compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37
os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016
nodename: ip-172-31-16-133
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 64137
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from kb_uwsgi.ini
*** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:11 2017] ***
compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37
os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016
nodename: ip-172-31-16-133
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/ubuntu/webapps/kenyabuzz
your processes number limit is 64137
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 769]
Mon Jan 30 10:28:11 2017 - [emperor] curse the uwsgi instance kb_uwsgi.ini (pid: 25612)
Mon Jan 30 10:28:14 2017 - [emperor] removed uwsgi instance kb_uwsgi.ini
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from kb_uwsgi.ini
*** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:16 2017] ***
compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37
os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016
nodename: ip-172-31-16-133
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/ubuntu/webapps/kenyabuzz
your processes number limit is 64137
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 769]
Mon Jan 30 10:28:16 2017 - [emperor] curse the uwsgi instance kb_uwsgi.ini (pid: 25613)
Mon Jan 30 10:28:19 2017 - [emperor] removed uwsgi instance kb_uwsgi.ini
*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from kb_uwsgi.ini
*** Starting uWSGI 2.0.14 (64bit) on [Mon Jan 30 10:28:22 2017] ***
compiled with version: 5.4.0 20160609 on 06 January 2017 11:55:37
os: Linux-4.4.0-53-generic #74-Ubuntu SMP Fri Dec 2 15:59:10 UTC 2016
nodename: ip-172-31-16-133
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
chdir() to /home/ubuntu/webapps/kenyabuzz
your processes number limit is 64137
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 769]
Mon Jan 30 10:28:22 2017 - [emperor] curse the uwsgi instance kb_uwsgi.ini (pid: 25614)
^C[emperor] *** RAGNAROK EVOKED ***
Mon Jan 30 10:28:25 2017 - [emperor] removed uwsgi instance kb_uwsgi.ini
Mon Jan 30 10:28:25 2017 - [emperor] unloyal bad behaving vassal found: kb_uwsgi.ini throttling it...
Mon Jan 30 10:28:25 2017 - The Emperor is buried.
这是uwsgi文件
# kb_uwsgi.ini file
[uwsgi]
http = :80
# Django-related settings
# the base directory (full path)
chdir = /home/ubuntu/webapps/kenyabuzz
# Django's wsgi file
module = kb.wsgi
# the virtualenv (full path)
home = /home/ubuntu/webapps/djangoenv
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = /tmp/kb.sock
# ... with appropriate permissions - may be needed
chmod-socket = 664
# clear environment on exit
#vacuum = true
答案 0 :(得分:0)
在uwsgi文件中配置了http端口80。默认情况下,不允许普通用户绑定到此端口。这就是为什么您得到bind(): Permission denied
的原因。您可以give permission给www数据用户使用该端口,也可以使用其他端口。