linux uwsgi 非root,nginx – 只能用root运行uwsgi

我正在准备使用nginx / uwsgi与烧瓶我正在开发的网站,但我遇到问题.注意,网站本身运行良好使用烧瓶的调试:5000端口,但我现在想投入生产.解释我做了什么

它是一个linode ubuntu 12.04LTS服务器,我安装它像这样:

# install nginx

sudo apt-get install python-software-properties

sudo add-apt-repository ppa:nginx/stable

sudo apt-get update

sudo apt-get upgrade --show-upgraded

sudo apt-get install nginx-full

# installing uwsgi

sudo apt-get install build-essential python-dev libxml2-dev

sudo apt-get install libc6 libexpat1 libgd2-xpm libgeoip1 libpam0g libpcre3 libssl1.0.0 libxml2 libxslt1.1 zlib1g

sudo pip install uwsgi

# python basics

sudo apt-get install python-pip build-essential python-dev

sudo pip install virtualenv

sudo pip install virtualenvwrapper

sudo mkdir -p /srv/www/li/

cd /srv/www/li/

virtualenv venv

source /srv/www/li/venv/bin/activate

pip install flask

然后我开始配置一切,但我已经遇到麻烦与uwsgi(不介意NGINX,这将是下一步.

sudo nano /etc/uwsgi/apps-available/li.xml

python

/run/uwsgi/app/li.socket

666

/srv/www/li

/srv/www/li

/srv/www/li/venv

li

/srv/www/li/li.py

app

4

60

8

1

/tmp/stats.socket

2000

512

256

192

sudo ln -s /etc/uwsgi/apps-available/li.xml /etc/uwsgi/apps-enabled/li.xml

但是,如果我运行它,我得到:

uwsgi --xml /etc/uwsgi/apps-enabled/li.xml

[uWSGI] parsing config file /etc/uwsgi/apps-enabled/li.xml

open("./python_plugin.so"): No such file or directory [core/utils.c line 4755]

!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!

*** Starting uWSGI 1.4.6 (64bit) on [Thu Feb 28 16:30:53 2013] ***

compiled with version: 4.6.3 on 28 February 2013 12:38:22

os: Linux-3.7.10-x86_64-linode30 #1 SMP Wed Feb 27 14:29:31 EST 2013

nodename: demo

machine: x86_64

clock source: unix

detected number of CPU cores: 4

current working directory: /run/uwsgi/app

detected binary path: /usr/local/bin/uwsgi

your processes number limit is 63594

limiting address space of processes...

your process address space limit is 536870912 bytes (512 MB)

your memory page size is 4096 bytes

*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***

detected max file descriptor number: 1024

lock engine: pthread robust mutexes

uwsgi socket 0 bound to UNIX address /run/uwsgi/app/li.socket fd 3

Python version: 2.7.3 (default, Aug 1 2012, 05:25:23) [GCC 4.6.3]

Set PythonHome to /srv/www/li/venv

*** Python threads support is disabled. You can enable it with --enable-threads ***

Python main interpreter initialized at 0xa86e20

your server socket listen backlog is limited to 100 connections

mapped 362120 bytes (353 KB) for 4 cores

*** Operational MODE: preforking ***

added /srv/www/li/ to pythonpath.

/srv/www/li/venv/local/lib/python2.7/site-packages/mongoengine/fields.py:744: FutureWarning: ReferenceFields will default to using ObjectId strings in 0.8, set DBRef=True if this isn't desired

warnings.warn(msg, FutureWarning)

WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xa86e20 pid: 14934 (default app)

*** uWSGI is running in multiple interpreter mode ***

spawned uWSGI master process (pid: 14934)

spawned uWSGI worker 1 (pid: 14940, cores: 1)

mapping worker 1 to CPUs: 0

spawned uWSGI worker 2 (pid: 14941, cores: 1)

mapping worker 2 to CPUs: 1

spawned uWSGI worker 3 (pid: 14942, cores: 1)

mapping worker 3 to CPUs: 2

spawned uWSGI worker 4 (pid: 14943, cores: 1)

unlink(): Operation not permitted [core/socket.c line 109]

bind(): Address already in use [core/socket.c line 141]

...brutally killing workers...

mapping worker 4 to CPUs: 3

VACUUM: unix socket /run/uwsgi/app/li.socket removed.

所以我得到unlink操作不允许和绑定地址已经在使用中的错误(旁边python_plugin错误,我也没有线索如何解决!).如果我运行sudo,它似乎工作正常 – >

sudo uwsgi --xml /etc/uwsgi/apps-enabled/li.xml

[uWSGI] parsing config file /etc/uwsgi/apps-enabled/li.xml

open("./python_plugin.so"): No such file or directory [core/utils.c line 4755]

!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!

*** Starting uWSGI 1.4.6 (64bit) on [Thu Feb 28 15:47:41 2013] ***

compiled with version: 4.6.3 on 28 February 2013 12:38:22

os: Linux-3.7.10-x86_64-linode30 #1 SMP Wed Feb 27 14:29:31 EST 2013

nodename: demo

machine: x86_64

clock source: unix

detected number of CPU cores: 4

current working directory: /run/uwsgi

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) ***

your processes number limit is 63594

limiting address space of processes...

your process address space limit is 536870912 bytes (512 MB)

your memory page size is 4096 bytes

*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***

detected max file descriptor number: 1024

lock engine: pthread robust mutexes

uwsgi socket 0 bound to UNIX address /run/uwsgi/app/li.socket fd 3

Python version: 2.7.3 (default, Aug 1 2012, 05:25:23) [GCC 4.6.3]

Set PythonHome to /srv/www/li/venv

*** Python threads support is disabled. You can enable it with --enable-threads ***

Python main interpreter initialized at 0x1fc9d00

your server socket listen backlog is limited to 100 connections

mapped 362120 bytes (353 KB) for 4 cores

*** Operational MODE: preforking ***

added /srv/www/li/ to pythonpath.

/srv/www/li/venv/local/lib/python2.7/site-packages/mongoengine/fields.py:744: FutureWarning: ReferenceFields will default to using ObjectId strings in 0.8, set DBRef=True if this isn't desired

warnings.warn(msg, FutureWarning)

WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1fc9d00 pid: 14755 (default app)

*** uWSGI is running in multiple interpreter mode ***

spawned uWSGI master process (pid: 14755)

spawned uWSGI worker 1 (pid: 14761, cores: 1)

mapping worker 1 to CPUs: 0

spawned uWSGI worker 2 (pid: 14762, cores: 1)

mapping worker 2 to CPUs: 1

spawned uWSGI worker 3 (pid: 14763, cores: 1)

mapping worker 3 to CPUs: 2

spawned uWSGI worker 4 (pid: 14764, cores: 1)

*** Stats server enabled on /tmp/stats.socket fd: 16 ***

mapping worker 4 to CPUs: 3

谁能帮帮我吗?由于www数据在www数据组中,他运行它,我尝试了一些东西:

sudo usermod -a -G www-data $USER

sudo chown -R $USER:www-data /srv/www/li

sudo chmod -R g+r+w+x /srv/www/li

sudo chown -R $USER:www-data /etc/uwsgi/apps-enabled

sudo chmod -R g+r+w+x /etc/uwsgi/apps-enabled

sudo chown -R $USER:www-data /run/uwsgi/app

sudo chmod -R g+r+w+x /run/uwsgi/app

但这真的没有帮助.我也尝试了一个tcp端口,而不是unix / run / uwsgi / app / port,没有任何区别…

这让我疯狂:(我希望有人对这里发生的事情有一个线索.

亲切的问候,

CARST

编辑:服务器重新启动后仍然给出一个错误,但是不同的:

geoadmin@demo:~$uwsgi --xml /etc/uwsgi/apps-enabled/li.xml

[uWSGI] parsing config file /etc/uwsgi/apps-enabled/li.xml

*** Starting uWSGI 1.4.6 (64bit) on [Thu Feb 28 18:47:36 2013] ***

compiled with version: 4.6.3 on 28 February 2013 12:38:22

os: Linux-3.7.10-x86_64-linode30 #1 SMP Wed Feb 27 14:29:31 EST 2013

nodename: demo

machine: x86_64

clock source: unix

detected number of CPU cores: 4

current working directory: /home/geoadmin

detected binary path: /usr/local/bin/uwsgi

your processes number limit is 63594

limiting address space of processes...

your process address space limit is 536870912 bytes (512 MB)

your memory page size is 4096 bytes

*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***

detected max file descriptor number: 1024

lock engine: pthread robust mutexes

bind(): No such file or directory [core/socket.c line 141]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值