jail 環境に rails4 お手軽構築
FreeBSD 9.2 で jail 環境内に rails4 のテスト環境を構築。
rbenv までは pkg でインストールし、それ以降の ruby 環境の構築は pkg に頼らない方針。
pkg の初期設定が古いので少し修正が必要だったのと、bundler が gem install sqlite3 する際のオプション指定が必要だった。
(ezjail-admin で jail 環境を最新の状態で再構築したところ、pkg 関係の初期設定は必要なくなった)
host# ezjail-admin create rails4 192.168.0.4 host# ezjail-admin console -f rails4 rails4# pkg rails4# cat <<EOF >/usr/local/etc/pkg.conf packagesite: pkg+http://pkg.FreeBSD.org/freebsd:9:x86:32/latest EOF rails4# pkg install rbenv ruby-build rails4# pkg install git rails4# pkg install sqlite3 rails4# sudo rails % rbenv install -list | grep 2\\. % rbenv install 2.0.0-p451 % rbenv system 2.0.0-p451 % cat <<EOF >>/root/.cshrc setenv PATH /root/.rbenv/shims:${PATH} rbenv rehash EOF % gem install bundler % bundle config build.sqlite3 --with-sqlite3-include=/usr/local/include --with-sqlite3-lib=/usr/local/lib % mkdir ~/hogehoge % cd ~/hogehoge % git init % bundle init % vi Gemfile % bundle install --path vendor/bundle % bundle exec rails new . --skip-bundle % vi Gemfile % bundle install --path vendor/bundle % bundle exec rails generate scaffold book title price:integer % bundle exec rake % bundle exec rake db:migrate % bundle exec rake server
なお、gem で手動で sqlite3 をインストールする際は次のようにオプションを指定する。
% gem install sqlite3 -- --with-sqlite3-include=/usr/local/include --with-sqlite3-lib=/usr/local/lib