[AmazonLinux] へ戻る
= はじめに
今回は、Amazon Linux への Rails4 のインストールについて、説明します。
Amazon Linux は「Amazon Linux AMI 2014.09 (HVM) - ami-35072834」を使用しました。
= ruby バージョンの確認
まず、インストールされている ruby のバージョンを確認して下さい。
{{{ code sh
ruby -v
}}}
下記のように、ruby 2.0 以上のバージョンが表示されていれば、OK です。
{{{ code sh
ruby 2.0.0p481 (2014-05-08 revision 45883) [x86_64-linux]
}}}
= Rails4 のインストール
gem コマンドで Rails4 をインストールします。
{{{ code sh
sudo gem install rails
}}}
[Rails4インストール結果]
= Rails new で作成したプロジェクトの必要モジュールのインストール
== bcrypt-ruby のインストール
[bcrypt_rubyのインストール]
== sqlite3 のインストール
sqlite3 の gem のインストールで、下記のようにエラーが表示されることがあります。
{{{ code sh
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.0 extconf.rb
checking for main() in -lpthread... yes
creating Makefile
make "DESTDIR="
g++ -I. -I/home/ec2-user/.gem/ruby/2.0/gems/libv8-3.16.14.7-x86_64-linux/vendor/v8/include -I/usr/include/ruby/2.0 -I/usr/include/ruby/2.0/ruby/backward -I/usr/include/ruby/2.0 -I. -Wall -g -rdynamic -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -m64 -o script.o -c script.cc
make: g++: Command not found
make: *** [script.o] Error 127
Gem files will remain installed in /home/ec2-user/.gem/ruby/2.0/gems/therubyracer-0.12.1 for inspection.
Results logged to /home/ec2-user/.gem/ruby/2.0/gems/therubyracer-0.12.1/ext/v8/gem_make.out
An error occurred while installing therubyracer (0.12.1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.1'` succeeds before bundling.
}}}
原因は、g++ がインストールされていないこと。therubyracer の gem がインストールされていないことにあります。
=== g++ のインストール
下記のコマンドで g++ をインストールして下さい。
{{{ code sh
sudo yum install gcc-c++
}}}
[g_plus_plusのインストール結果 g++ のインストール結果]
=== therubyracerのインストール
下記のコマンドで、therubyracer をインストールして下さい。
{{{ code sh
gem install therubyracer -v '0.12.1'
}}}
{{{ code sh
Building native extensions. This could take a while...
Successfully installed therubyracer-0.12.1
Parsing documentation for therubyracer-0.12.1
Installing ri documentation for therubyracer-0.12.1
Done installing documentation for therubyracer after 0 seconds
1 gem installed
}}}
ようやく、sqlite3 がインストールできます。
{{{ code sh
bundle update sqlite3
}}}
[AmazonLinux] へ戻る