1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

さくらのVPSにRubyをインストール

Last updated at Posted at 2020-06-01

環境等は以下の記事をご参照ください。
さくらのVPSにSSH接続+最低限のセキュリティ対策

Gitをインストール

まずはgit cloneを使うためにgitをインストールします。

$ sudo yum -y install git
$ git --version

rbenvをインストール

Rubyのバージョンを管理するツール、rbenvをインストールします。

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build #'rbenv install'コマンドの実行に必要なプラグイン

依存パッケージをインストール

rubyをインストールするための関連するパッケージです。これがないと、rbenv installの際にコケるらしいです。

$ yum -y install bzip2 gcc openssl-devel readline-devel zlib-devel

rbenvの読み込み設定

rbenvコマンドを使える用にするために、シェル起動時読み込むbash_profileを編集します。

$ vi ~/.bash_profile
~/.bash_profile
# 省略
PATH=$PATH:$HOME/bin

export PATH
export PATH="$HOME/.rbenv/bin:$PATH" # 追記
eval "$(rbenv init -)" # 追記
$ source ~/.bash_profile
$ rbenv -v

Rubyをインストール

rbenvの設定が終わったので、いよいよRubyのインストールです。

$ rbenv install 2.4.1
$ rbenv global 2.4.1
$ rbenv rehash
$ ruby -v

bundlerをインストール

gemの管理をいい感じにするツールbundlerをインストールしましょう。

$ gem install bundler

node.js、yarnをインストール

Rails6を動かすためにはyarnが必須です。

$ yum install -y nodejs npm --enablerepo=epel
$ npm install -g yarn

参考

1
1
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?