320
299

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 5 years have passed since last update.

Ruby on RailsAdvent Calendar 2015

Day 24

最速!MacでRuby on Rails環境構築

Last updated at Posted at 2015-12-12

homebrewをインストール

http://brew.sh/index_ja.html

Ruby編

rbenvをインストール

$ brew install rbenv
$ brew install ruby-build
$ rbenv version
2.2.3 (set by ******)

bash_profileに追記

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile

Rubyをインストール

$ rbenv install 2.6.1

rbenvのバージョンを切り替える

$ rbenv global 2.6.1
$ rbenv rehash
$ ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
$ gem -v
3.0.1

bundlerインストール

$ gem install bundler
$ bundle -v
Bundler version 2.0.1

MySQL編(SQLiteを使用する場合は不要)

MySQLをインストール

$ brew install mysql

MySQL起動

$ mysql.server start
Starting MySQL
SUCCESS! 

Rails編

てきとうなワークスペース

$ mkdir ~/workspace
$ cd ~/workspace

bundle init

$ bundle init
Writing new Gemfile to /Users/*****/workspace/Gemfile

できあがったGemfileのRailsのコメントアウトを外す

Gemfile
# A sample Gemfile
source "https://rubygems.org"

gem "rails"

Railsインストール

$ bundle install --path=vendor/bundle
Fetching gem metadata from https://rubygems.org/...........

Railsアプリケーション作成

$ bundle exec rails new .

聞かれたやつは全部 y

ライブラリインストール

$ bundle install --path=vendor/bundle
Fetching gem metadata from https://rubygems.org/...........

Railsアプリケーション起動

$ bundle exec rails s
PC-10214:workspace a13161$ bundle exec rails s
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-12-13 02:24:12] INFO  WEBrick 1.3.1
[2015-12-13 02:24:12] INFO  ruby 2.2.3 (2015-08-18) [x86_64-darwin14]
[2015-12-13 02:24:12] INFO  WEBrick::HTTPServer#start: pid=55996 port=3000

おわり

http://localhost:3000/ へアクセスしてみましょう!

320
299
2

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
320
299

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?