nginx + uWSGI for Raspberry pi

nginx も uWSGI も現時点の最新版(2014/06/01)を使います。

nginx 1.6.0
uWSGI 2.0.4 (32bit)

apt-get でさらっとインストールすると 超古いバージョンが入ってしましました。 最新版を入れてみたい人はこちらを参考にしてください。

インストール

nginx 1.6.0

/etc/apt/sources.list

deb http://nginx.org/packages/debian/ wheezy nginx  
deb-src http://nginx.org/packages/debian/ wheezy nginx

2行を追記。

コマンド実行

$ sudo apt-get update
$ sudo apt-get build-dep nginx
$ sudo apt-get source nginx
$ cd nginx-1.6.0
$ sudo dpkg-buildpackage -uc -b
$ sudo dpkg -i nginx_1.6.0-1~wheezy_armhf.deb

参考: http://mkws.blogspot.jp/2013/10/nginx-raspberry-pi.html

uwsgi 2.0.4 インストール

$ sudo pip install uwsgi

参考: http://uwsgi-docs.readthedocs.org/en/latest/Install.html

各設定

/etc/nginx/conf.d/default.conf

server {
    listen       80;
    server_name  localhost;

    location /hello {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:9090;
    }
}

/etc/uwsgi/apps-available/hello.ini

[uwsgi]
socket = 127.0.0.1:9090
enable-threads = true
single-interpreter = true
master = true
process = 2
uid = nginx
gid = nginx
pythonpath = /usr/share/nginx/html
module = hello
daemonize = /var/log/uwsgi/access.log

/etc/uwsgi/apps-enabled

$ ln -s ../apps-available/hello.ini

/usr/share/nginx/html/hello.py

import uwsgi
def myapp(environ, start_response):
  start_response('200 OK', [('Content-Type', 'text/plain')])
  yield 'Hello uWSGI World\n'

uwsgi.applications = {
  '': myapp
}

是非お試しあれ

Raspberry Pi Type B 512MB

Raspberry Pi Type B 512MB

Raspberry Piユーザーガイド

Raspberry Piユーザーガイド