欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nginx+uwsgi+python web发布

程序员文章站 2022-07-12 17:26:26
...
1,nginx,python web的环境已经配置好了,重点介绍uwsgi的使用

2,python web程序
david@david-server:~/python$ cat start.py
import web

urls = (
    '/.*', 'index'
)

class index:
    def GET(self):
        return 'Hello David!'

application = app.wsgifunc()



3,uwsgi的安装
david@david-server:~/python$ sudo apt-get install python2.6-dev libxml2-dev

david@david-server:~/python$ wget http://projects.unbit.it/downloads/uwsgi-1.2.5.tar.gz
david@david-server:~/python$ tar -xvf uwsgi-1.2.5.tar.gz

david@david-server:~/python$ sudo make

david@david-server:~/python$ sudo cp uwsgi /usr/bin


4,启动uwsgi
david@david-server:~/python$ uwsgi -s 127.0.0.1:9003 -p 10 -M -d /dev/null -l 10000 -limit-as 512 -t 30 --file start.py -callable application


5,nginx+uwsgi配置
david@david-server:~/python$ cat conf/t3.conf 
server {
        listen 80;
        server_name t3.i-david.org;

        root /home/david/python/test003;
        index index.html index.htm;

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


6,OK了