LoginSignup
31
22

More than 5 years have passed since last update.

まっさらなCentOS6.5(AWS)にRails4.1.1とruby 2.1.2p95を入れる

Posted at

rbenvのインストール

rbenvをgit経由でインストールするため、gitをインストール
yum -y install git

rbenvをgitからダウンロードしてインストール
インストール先を~/.rbenvに指定する
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv

bash_profileにrbenvの起動の設定を記述
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

ruby2のインストール

ruby-buildのインストール
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

ruby 2.1.2をインストール
rbenv install -v 2.1.2

ハマった

Installing ruby-2.1.2...
/tmp/ruby-build.20140618135731.7623/ruby-2.1.2 /tmp/ruby-build.20140618135731.7623 ~
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in /tmp/ruby-build.20140618135731.7623/ruby-2.1.2':
configure: error: no acceptable C compiler found in $PATH
See
config.log' for more details
BUILD FAILED
Inspect or clean up the working tree at /tmp/ruby-build.20140618135731.7623
Results logged to /tmp/ruby-build.20140618135731.7623.log
Last 10 log lines:
/tmp/ruby-build.20140618135731.7623/ruby-2.1.2 /tmp/ruby-build.20140618135731.7623 ~
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in /tmp/ruby-build.20140618135731.7623/ruby-2.1.2':
configure: error: no acceptable C compiler found in $PATH
See
config.log' for more details
BUILD FAILED
Inspect or clean up the working tree at /tmp/ruby-build.20140618135731.7623
Results logged to /tmp/ruby-build.20140618135731.7623.log
Last 10 log lines:
/tmp/ruby-build.20140618135731.7623/ruby-2.1.2 /tmp/ruby-build.20140618135731.7623 ~
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in /tmp/ruby-build.20140618135731.7623/ruby-2.1.2':
configure: error: no acceptable C compiler found in $PATH
See
config.log' for more details`

Cコンパイラが入ってない?
と思ったので、
yum install gccして
再度rbenv install -v 2.1.2

すると

The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

BUILD FAILED

Inspect or clean up the working tree at /tmp/ruby-build.20140618141611.7977
Results logged to /tmp/ruby-build.20140618141611.7977.log

Last 10 log lines:
io-console 0.4.2
json 1.8.1
minitest 4.7.5
psych 2.0.5
rake 10.1.0
rdoc 4.1.0
test-unit 2.1.2.0
installing rdoc: /root/.rbenv/versions/2.1.2/share/ri/2.1.0/system
installing capi-docs: /root/.rbenv/versions/2.1.2/share/doc/ruby
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?

今度はopensslが入ってないみたいなので、
yum -y install openssl-devel

終わったっぽい

再度 rbenv install -v 2.1.2をする

ただrbenvに入っただけなので、
rbenv global 2.1.2
として環境全体にrubyのバージョンを適用する

バージョンの確認
ruby -v

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

良さそう

rails 4のインストール

早速インストール
gem install --no-ri --no-rdoc rails

適用する
rbenv rehash

さっそく適当にプロジェクトを作ってみる
rails new demo
が、sqlite3がないよ!と言われるので
yum -y install sqlite-devel

で、再度
rails new demo
をすると…。
プロジェクトができたっぽい

ディレクトリ移動して、rails sでサーバーを立ち上げてみると…?

detect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

と言われる(´・ω・`)

勝手に、
http://mymemo.weby117.com/develop/ruby-geminstall-error_3.html
を参考にさせていただき、
gem 'therubyracer'をgemfileに追加。

そしてbundle installすると…

こんなエラーがでた

creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling string.cc
make: g++: Command not found
make: *** [string.o] Error 127

make failed, exit code 2

g++のコマンドを使えるようにすれば良いと思ったので、
yum install gcc-c++

で、再度bundle installすると

Your bundle is complete!
Use bundle show [gemname] to see where a bundled gem is installed.

良さそう
最後に、rails serverすると…

=> Booting WEBrick
=> Rails 4.1.1 application starting in development on http://0.0.0.0:3000
=> Run rails server -h for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
[2014-06-20 12:00:00] INFO WEBrick 1.3.1
[2014-06-20 12:00:00] INFO ruby 2.1.2 (2014-05-08) [x86_64-linux]
[2014-06-20 12:00:00] INFO WEBrick::HTTPServer#start: pid=2989 port=3000

良さそう

31
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
22