Artorius

快速使用uwsgi部署

April 14, 2013 | 3 Minute Read

之前尝试在阿里云部署一个bottle.py写的web服务,选择了unbuntu12.04,一穷二白的ubuntu上用uwsgi部署还挺简单的。这里简单记录一下。

先要改一改程序代码,声明一个application

application = bottle.app()

然后安装uwsgi,demo.py就是修改过的bottle的代码。

这里我遇到了— unavailable modifier requested: 0 --,要安装uwsgi-plugin-python,并且uwsgi启动时候添加--plugin python

一些uwsgi的操作看这里

apt-get install uwsgi uwsgi-plugin-python
uwsgi --socket :8000 --plugin python --file demo.py --processes 4 --pidfile /tmp/demo.pid --touch-reload=/tmp/restart -d uwsgi.log

安装nginx

apt-get install libpcre3 libpcre3-dbg libpcre3-dev
apt-get install zlib1g zlib1g-dbg zlib1g-dev
apt-get install make
cd /path/to/nginx
./configure
make
make install

最后配置nginx。默认安装路径在/usr/local/nginx/conf/nginx.conf

server {
    listen       80;
    server_name  demo.artori.us;

    location /static/ { alias /home/root/demo/static/; }

    location / {
        uwsgi_pass      127.0.0.1:8000;
        include         uwsgi_params;
    }
}

自此搞定

via: