LoginSignup
8
7

More than 5 years have passed since last update.

unicornのインストール

Posted at

Gemでユニコーンをインストールすろ

gem install unicorn-rails

gem install unicorn

ユニコーンの設定ファイルを作成

vim RAILS_ROOT/config/unicorn.rb
RAILS_ROOT/config/unicorn.rb
APP_PATH = "/var/www/ruby/rss"

worker_processes 2

working_directory "/var/www/ruby/rss"

listen 3000

pid APP_PATH + "/tmp/pids/unicorn.pid"
stderr_path APP_PATH + "/log/unicorn.log"
stdout_path APP_PATH + "/log/unicorn.log"


preload_app true

ユニコーンでRailsを起動

bundle exec unicorn_rails -E development -c config/unicorn.rb

Nginxの設定ファイルを作成

vim /etc/nginx/nginx.conf
/etc/nginx/nginx.conf
upstream abgata.org {
    #server 127.0.0.1:3000;
    server unix:/var/tmp/rss.sock;
}

server {
    listen 80;
    server_name abgata.org;

    root /var/www/ruby/rss/public;

    access_log /var/log/rss_access.log;
    error_log  /var/log/rss_error.log;

    location / {
      if (-f $request_filename) {
        break;
      }

      proxy_set_header X-Real-IP  $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_pass http://abgata.org;
    }

    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
      # expires 1y;
    }
}

ヴァーチャルホストの設定

sudo vim /etc/nginx/sites-avalable/default
/etc/nginx/sites-avalable/default
server {
        listen 80 default_server;
        server_name _;
        deny all;
}

設定を反映させるファイルのシンボリックリンクを作成

sudo ln -s /etc/nginx/sites-avalable/default /etc/nginx/sites-enabled/

Nginxを再起動して設定を反映

chkconfig nginx on

service nginx start

service nginx reload
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7