当前位置:首页 > 开发 > 互联网 > 正文

ubuntu+uwsgi+nginx+web.py安装配置记录

发表于: 2012-05-18   作者:cn.popeye   来源:转载   浏览:
摘要:   install: 1. sudo apt-get install python-dev 2. sudo apt-get install mysql-server python-mysql 3. sudo apt-get install redis-server python-redis  4. sudo apt-get install subversion 5.

 

install:

1. sudo apt-get install python-dev

2. sudo apt-get install mysql-server python-mysql

3. sudo apt-get install redis-server python-redis 

4. sudo apt-get install subversion

5. sudo apt-get install python-webpy 

6. sudo apt-get install nginx uwsgi-extra

7. install uwsgi

 $ sudo apt-get install libxml2

 $ hg clone http://projects.unbit.it/hg/uwsgi-1.2

 $ cd /uwsgi-1.2

 $ python uwsgiconfig.py --build

 $ python setup.py install

 

 ***:$ ubuntu 仓库的uwsgi貌似版本有问题,会提示-w参数无效 or --module 参数无效

 

8. install PIL Image about (if you want)

   参见:PIL安装记录,编译支持jpeg png

 

9.configure uwsig&nginx

  File: /etc/nginx/sites-enabled/myapp

server {
        listen   80; ## listen for ipv4; this line is default and implied
        server_name localhost;

        root   /data/www/myapp;
        index  index.html index.htm;

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


        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
                expires      30d;
        }

        location ~ .*\.(js|css)?$ {
                expires      1h;
        }

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /var/www/nginx-default;
        }

        # deny access to .htaccess files, if Apache's document root
        location ~ /\.ht {
                deny  all;
        }

 

     File: /etc/uwsgi/apps-enabled/myapp.xml

 

<uwsgi id="myapp">
  <socket>127.0.0.1:9001</socket>
  <module>myapp</module>
  <master />
  <pythonpath>/data/www/myapp</pythonpath>
  <chdir>/data/www/myapp</chdir>
  <processes>2</processes>
  <workers>4</workers>
  <memory-report/>
  <pidfile>/tmp/uwsgi_myapp.pid</pidfile>
  <max-requests>10000</max-requests>
  <daemonize>/var/log/uwsgi_myapp.log</daemonize> 
</uwsgi>
 

 

 

 

start uwsgi:
$ uwsgi -x /etc/uwsgi/apps-enabled/myapp.xml
 

 

 

stop uwsgi:
$ uwsgi --stop
  or
$ kill -SIGINT `cat /tmp/uwsgi_myapp.pid`
 

 

 

reload uwsgi:
$ uwsgi --reload
  or
$ kill -SIGHUP `cat /tmp/uwsgi_myapp.pid`
 

 

 

pause uwsgi:
$ uwsgi --pause
  or
$ kill -SIGTSTP `cat /tmp/uwsgi_myapp.pid`
 

 

 

suspend uwsgi:
$ uwsig --suspend
  or
$ kill -SIGTSTP `cat /tmp/uwsgi_myapp.pid`
 

 

 

resume uwsgi:
$ uwsgi --resume
  or
$ kill -SIGTSTP `cat /tmp/uwsgi_myapp.pid`
 

 

 

 

ubuntu+uwsgi+nginx+web.py安装配置记录

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号