rackhubでrails+nginx+unicornを80ポートで動かしてみたメモ


便利スクリプトがgistに公開されてるんで、基本的に使ってみただけなんですが、いくつか気づいた点もあったのでメモしておきます。

https://gist.github.com/2129714


rackを作成したらsshでログインして、railsインストールしてrails newします

gem install rails --no-rdoc --no-ri
rails new sample_app
cd sample_app
vi Gemfile


railsは今だと3.2.2が入りました。
以下をGemfileに記述します。

gem 'therubyracer'
gem 'unicorn'
bundle install
export RAILS_ROOT=`pwd`
rails g scaffold bookmark title:string url:string
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake assets:precompile RAILS_ENV=production
vi config/routes.rb

config/routes.rbを編集してルートパスをscaffoldで作成した機能のindexに向けます

root :to => "bookmarks#index"

index.htmlを消します。

rm public/index.html
sudo vi /rhb/etc/nginx/nginx.conf

nginx.confのデフォルトで記述してあるserver {..}をコメントアウトします。
これをやらないとデフォルトで用意されている/rhb/nginx-1.0.11/html/index.htmlが表示されました。


あらかじめnginxを起動しておきます。

sudo /etc/init.d/nginx start

gistのスクリプトを最後に実行しますが、それだけだとnginxが起動しないみたいです。


で、便利スクリプトを実行

bash -s stable < <(curl -s https://raw.github.com/gist/2129714/install.sh)


ブラウザでアクセスすればrailsのページが表示されます。