spangled shalalala blog

諦めたらそこで試合終了だよ。

さくらVPSにインストールしたUbuntu 16.04へrbenvでRubyの開発環境を整える

Ubuntu 16.04での環境構築を引続き。

前回までのあらすじは以下のとおり

前提

  • OS: Ubuntu 16.04
  • さくらVPS 1Gプランを使用してSSH接続
  • gitインストール済
  • rubyのインストールはrbenvを使用して行う

参考資料

インストール手順

#rbenvをgit clone
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv

#.bashrcへpatthを追加
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> .bashrc
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

#再度rubyをインストール
$ rbenv install 2.3.3

#エラーが発生...
#/tmp/ruby-build.20170906234728.2856 ~
#perl: warning: Setting locale failed.
#perl: warning: Please check that your locale settings:
#        LANGUAGE = (unset),
#        LC_ALL = (unset),
#        LC_CTYPE = "ja_JP.UTF-8",
#        LANG = "ja_JP.UTF-8"
#    are supported and installed on your system.
#perl: warning: Falling back to the standard locale ("C").
#/tmp/ruby-build.20170906234728.2856/ruby-2.3.3 /tmp/ruby-build.20170906234728.2856 ~
#checking for ruby... false
#checking build system type... x86_64-pc-linux-gnu
#checking host system type... x86_64-pc-linux-gnu
#checking target system type... x86_64-pc-linux-gnu
#checking for gcc... no
#checking for cc... no
#checking for cl.exe... no
#configure: error: in `/tmp/ruby-build.20170906234728.2856/ruby-2.3.3':
#configure: error: no acceptable C compiler found in $PATH
#See `config.log' for more details

#必要そうなパッケージを準備
$ sudo apt-get update
$ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libpq-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

#再度rubyをインストール
$ rbenv install 2.3.3
$ rbenv rehash
$ rbenv global 2.3.3

#バージョン確認ができればrubyの設定OK
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux]

#bundlerのインストール
$ gem install bundler