unicorn + rails + nginx 設定メモ
/etc/nginx/nginx.conf
変更なし
/etc/nginx/conf.d/default.conf
----------
upstream api {
server unix:/tmp/unicorn.sock;
}
server {
listen 80;
server_name localhost;
location / {
root /var/www;
index index.html;
ssi on;
}
}
server {
listen 80;
server_name hoge.net;
location / {
proxy_pass http://api;
}
}
----------
unicorn.conf
----------
worker_processes 1
listen '/tmp/unicorn.sock'
stderr_path "log/unicorn.log"
stdout_path "log/unicorn.log"
preload_app true
pid "tmp/pids/unicorn.pid"
----------
db setup
rake db:migrate RAILS_ENV="production"
rake db:reset RAILS_ENV="production"
unicorn起動
unicorn_rails -c config/unicorn.conf -D -E production
unicorn停止
kill -QUIT pid
kill -HUP pid