前提
・Rails環境(Ruby2.0.0-p247 + Rails4.0.0)は構築済み。
・gemにunicornを指定してインストール済み。
・apt-getでnginxをインストール済み。
・Railsのプロジェクト名は「greedents」
手順
/etc/nginx/conf.d/greedents.confを作成
$ sudo cat <<EOS>greedents.conf upstream greedents { server unix:/tmp/greedents.sock; } server { listen 80; server_name greedents; location / { proxy_pass http://greedents/; } location = /robots.txt { access_log off; log_not_found off; } location = /favicon.ico { access_log off; log_not_found off; } } EOS
nginxを再起動
sudo service nginx restart
config/unicorn.rbを設定
listen '/tmp/greedents.sock' pid '/tmp/greedents.pid' stdout_path '/path_to_rails_app/log/unicorn.stdout.log' stderr_path '/path_to_rails_app/log/unicorn.stderr.log'
unicornの起動
bundle exec unicorn_rails -E development -c config/unicorn.rb -D