LoginSignup
28
29

More than 5 years have passed since last update.

CentOS 7でのRuby on Rails動作環境を構築する

Last updated at Posted at 2016-06-28

既に色々な方が書かれており、目新しい事はなにもないですが、備忘録も兼ねてアップロードします。

前提

  • CentOS7 インストール済み
  • Ruby 2.3.1
  • Rails 4.2.6
  • SSHにて実行

手順

1. 必要なパッケージのインストール

yum install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel

2. rbenvインストール

git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv
echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile
echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile
echo 'eval "$(rbenv init -)"' >> /etc/profile

SSHを切断し、再接続して

rbenv --version

を実行して、バージョンの確認をする

3. ruby-buildインストール

git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build

4. rubyインストール

rbenvでインストールできるRubyのバージョン一覧確認

rbenv install -l

Rubyのバージョンを指定してインストール

rbenv install -v 2.3.1
rbenv rehash

使用するRubyのバージョンを指定

rbenv global 2.3.1

バージョンを確認する

ruby -v

5. Railsインストール

gem update --system
gem install --no-ri --no-rdoc rails
gem install bundler
rbenv rehash

バージョンを確認する

rails -v

MySQLを使用する場合

こちらを参考にMySQLのインストールからRubyでの使用方法までを記載しています。
MySQLのインストール手順

28
29
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
28
29