Развертывание и подготовка Production Environment (Nginx и Unicorn)
mkdir -p /tmp/pids/
mkdir -p /tmp/logs/
$ cd $PROJECT_HOME
$ vi Gemfile
$ gem 'unicorn'
$ bundle install
$ vi config/unicorn.rb
working_directory File.expand_path("../..", __FILE__)
worker_processes 2
listen "/tmp/unicorn.sock"
timeout 30
pid "/tmp/unicorn_rails3demo.pid"
# stdout_path "/tmp/logs/unicorn.log"
# stderr_path "/tmp/logs/unicorn.log"
working_directory "/rails_projects/demo/nginx/demo"
pid "/tmp/pids/unicorn.pid"
stderr_path "/tmp/logs/unicorn.log"
stdout_path "/tmp/logs/unicorn.log"
listen "/tmp/unicorn.rails3demo.sock"
worker_processes 2
timeout 30
$ bundle exec unicorn -c config/unicorn.rb
=========================================================
=========================================================
NGINX
# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.orig
vi /etc/nginx/conf.d/default.conf
upstream unicorn {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80 default_server;
root /public/;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri/index.html $uri @unicorn;
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
}
# service nginx restart