Bottle + UWSGI + Nginx 搭建

pylist 104

Bottle + UWSGI + Nginx 环境搭建

Debian or ubuntu

aptitude install uwsgi uwsgi-plugin-python python-bottle nginx

bottle

from bottle import run, default_app
@route('/')
def home():
    return "I am running under nginx and uwsgi!"
if __name__ == "__main__":
    run(host='0.0.0.0', port=8080)
else:
    application = default_app()

试试 python app.py

Edit /etc/uwsgi/apps-available/bottle.ini

[uwsgi]
socket = /run/uwsgi/app/bottle/socket
chdir = /var/www/bottle
master = true
plugins = python
file = app.py
uid = www-data
gid = www-data

ln -s /etc/uwsgi/apps-available/bottle.ini /etc/uwsgi/apps-enabled/bottle.ini

service uwsgi restart

nginx

upstream _bottle {
    server unix:/run/uwsgi/app/bottle/socket;
}

server {
    listen [::]:80;
    listen 80;
    server_name deb.ngx.cc;
    root /var/www/bottle;

    location / {
        try_files $uri @uwsgi;
    }

    location @uwsgi {
        include uwsgi_params;
        uwsgi_pass _bottle;
    }
}

service nginx restart

登录发表评论

桂公网安备 45122402000014号