我正在准备使用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
sgi>
sgi/app/li.socketsgi-file>/srv/www/li/li.pysgi-file>
arakiri>60arakiri>
cpu-affinity>1cpu-affinity>
.socket RSS>192RSS>
sgi>
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,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,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]
最佳答案
这一直是我在谷歌的第一个结果,这个页面对我来说相对没有帮助,所以我要补充一下我的答案,尽管回想起来是相当明显的.
我的问题是我的stats socket的权限问题.如果您更改uWsgi配置的uid或gid参数,请确保您使用chmod或rm所有旧套接字/ pid及其父文件夹.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。