昨日、rvmで念願のRubyをインストールしましたので、お目当ての
Railsをインストールして、とりあえず起動してみる事に!
とりあえずsqlite3をインストールしました
必須かどうか知りません。
$ gem install sqlite3
sqlite-develが無いと言われて困ったので、インストールする
$ yum install sqlite-devel
この、develって物、開発用ファイルを含む物だそうで、ヘッダーファイルやらが含まれるそうです。
改めて
$ gem install sqlite3
railsインストール!!
$ gem install rails
こちらはすんなり終了。
railsで新規プロジェクト(アプリケーション)を作る
$ cd /var/www/rails/ #どこか好きな所
$ rails new helloApp
$ cd helloApp
これだけ!?これだけでもうスケルトンが出来てるようです。
便利な世の中です。
さて、早速ブラウザからアクセスしたいです。
$ rails s
でサーバを立ち上げます。
が。
`autodetect': Could not find a JavaScript runtime.
エラーがでます。ググると
gem 'execjs'
gem 'therubyracer'
この二つをGemfile
に追加すれば動く様です。
これは、Rails3.2から必要になったそです。
最初から追加しておいて欲しいで(ry
さて、追加して
$ bundle install
で、適応させます。
が。
An error occurred while installing therubyracer (0.11.0), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.11.0'` succeeds before bundling.
はいはい。
$ gem install therubyracer
$ bundle install
が。
An error occurred while installing therubyracer (0.11.0), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.11.0'` succeeds before bundling.
おなじじゃねーか。
これは、よくエラー文を読むしか無いですね。
そうすると、こんな一文があります。
If you don't want to bother with all that, there is a
rubygem that will do all this for you. You can add
following line to your Gemfile:
gem 'libv8', '~> 3.11.8'
ということなので、おとなしくGemfile
に
gem 'libv8', '~> 3.11.8'
を追加しておきます。
$ bundle install
…
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
今度は成功です!
さて
$ rails s
=> Booting WEBrick
=> Rails 3.2.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
起動しました。
こいつでサーバの3000番ポートにアクセスすれば、アプリケーションの画面が表示されます。
ウッひょひょい