7. rails環境の作成(pkun)
7.1. ディレクトリの作成
# sudo mkdir -p /var/www/app
7.2. 所有者の設定
# sudo chown pkun:pkun /var/www/app
7.3. アプリディレクトリに移動
# cd /var/www/app
7.4. Gemfile作成
railsのバージョンを指定してインストール出来るようにする
# bundle init
# echo 'gem "rails", "5.2.0"' >> Gemfile ※Gemfileにrailsを追加
# bundle install --path vendor/bundle
【表示結果】
①Writing new Gemfile to /var/www/app/Gemfile
②gem "rails", "5.2.0"
7.5. bundle exec省略設定
# curl -L https://github.com/gma/bundler-exec/raw/master/bundler-exec.sh > ~/.bundler-exec.sh
7.6. 「.bundler-exec.sh」の編集
# vi ~/.bundler-exec.sh
【編集内容】一番最後に移動して「rails」を追記(赤文字部分)
define-bundler-aliases
unset -f define-bundler-aliases
7.7. 「.bashrc」の編集
# vi ~/.bashrc
【編集内容】 一番最後に移動して追記(赤文字部分)
# "bundle exec" shortcut setting
[ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh
7.8. 「.bashrcの反映」
# source ~/.bashrc
7.9. rails version確認
# # rails -v
【表示結果】
Rails 5.2.0