LoginSignup
15
15

More than 5 years have passed since last update.

Ruby on Rails on AWS

Last updated at Posted at 2015-03-07

ゴール

素の状態のAWS EC2にRuby on Railsをセットアップする。

事前準備

  • AWS EC2が起動さす(AWS Linux)
  • sshで入る

やったこと

rubyは最初から2.0が入ってたのでそのまま使う。
以下Railsインストール作業。

$ sudo yum update
$ sudo gem install rails #エラー
...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.0 extconf.rb
mkmf.rb can't find header files for ruby at /usr/share/ruby/include/ruby.h
$ sudo yum -y install ruby-devel
$ sudo yum -y install ruby-devel
$ sudo yum -y install gcc
$ sudo yum -y install sqlite-devel
$ sudo yum -y install gcc-c++ 
$ sudo gem install rails #ちょっと進んだ
...
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

nokogiriがビルドできてないらしい。リンクページによると、

Troubleshooting Ubuntu / Debian Installation
It’s possible that you don’t have the zlib development header files installed on your system.

怪しい。探してみる。

$ yum search zlib
...
zlib-devel.x86_64 : Header files and libraries for Zlib development

入れてみる。

$ sudo yum install -y zlib-devel.x86_64
$ sudo gem install rails #ちょっと進んだ2
...
Running 'patch' for libxml2 2.9.2... ERROR, review '/usr/local/share/ruby/gems/2.0/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened.
*** extconf.rb failed ***

patch.log見てみる。patchが入ってなかった。入れる。

$ sudo yum install -y patch
$ sudo gem install rails #OK ぽい
...
Done installing documentation for nokogiri, loofah, rails-html-sanitizer, rails-deprecated_sanitizer, rails-dom-testing, builder, erubis, actionview, actionpack, activemodel, arel, activerecord, globalid, activejob, mime-types, mail, actionmailer, rake, thor, railties, bundler, hike, multi_json, tilt, sprockets, sprockets-rails, rails after 396 seconds
27 gems installed

$ rails -v
Rails 4.2.0

Done!

15
15
1

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
15
15