環境
CentOS 6.6
必要なライブラリーをインストールする
$ sudo yum install -y git nginx nodejs
MongoDB のインストールと起動
# /etc/yum.repos.d/mongodb-org.repo
[mongodb-org]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
$ sudo yum install -y mongodb-org
$ sudo service mongod start
$ sudo chkconfig mongod on
Nginx の設定
upstream errbit {
server unix:/var/www/vhost/errbit/tmp/sockets/unicorn.sock;
}
server {
listen *:80;
server_name errbit.example.com;
server_tokens off;
root /var/www/vhost/errbit/public;
location / {
try_files $uri $uri/index.html $uri.html @errbit;
}
location ~ ^/(assets)/ {
root /var/www/vhost/errbit/public;
access_log off;
}
location @errbit {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://errbit;
}
}
Nginx の起動
$ sudo service nginx start
Errbit のインストール
$ sudo mkdir -p /var/www/vhost
$ cd /var/www/vhost
$ sudo git clone https://github.com/errbit/errbit.git
$ sudo chown op:op -R errbit/
$ cd errbit/
$ bundle install --path vendor/bundle
$ bundle exec rake errbit:bootstrap
$ bundle exec rake assets:precompile RAILS_ENV=production
$ cp config/unicorn.default.rb config/unicorn.rb
unicorn の設定
worker_processes 3
timeout 30
preload_app true
app_path = '/var/www/vhost/errbit'
working_directory = app_path
listen File.expand_path('tmp/sockets/unicorn.sock', app_path)
pid File.expand_path('tmp/pids/unicorn.pid', app_path)
stderr_path File.expand_path('log/unicorn.stderr.log', app_path)
stdout_path File.expand_path('log/unicorn.stdout.log', app_path)
before_fork do |server, worker|
old_pid = "#{server.config[:pid]}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
Errbit の起動
$ bundle exec unicorn -c config/unicorn.rb -E production -D

参考ページ
errbit/errbit · GitHub