Ruby on Rail 설치

Ubuntu 14.04 LTS에 Ruby on Rail 설치하기

필요한 레파지토리 업데이트와 필요한 패키지 설치

sudo apt-get update

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev

rbenv를 이용해서 설치

cd

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

echo ‘export PATH="$HOME/.rbenv/bin:$PATH"’ >> ~/.bashrc

echo ‘eval “$(rbenv init -)”’ >> ~/.bashrc

exec $SHELL

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

echo ‘export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"’ >> ~/.bashrc

exec $SHELL

rbenv install 2.3.1

rbenv global 2.3.1

ruby -v

bundler 설치

gem install bundler

git 설정.

git config --global color.ui true

git config --global user.name “YOUR NAME”

git config --global user.email “YOUR@EMAIL.com

ssh-keygen -t rsa -b 4096 -C “YOUR@EMAIL.com

cat ~/.ssh/id_rsa.pub

ssh -T git@github.com

설치

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

sudo apt-get install -y nodejs

gem install rails -v 4.2.6

rbenv rehash

rails -v

Rails 4.2.6

MySQL 설치

sudo apt-get install mysql-server mysql-client libmysqlclient-dev

마무리

#### If you want to use SQLite (not recommended)
rails new myapp

#### If you want to use MySQL
rails new myapp -d mysql

#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql

# Move into the application directory
cd myapp

# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified

# Create the database
rake db:create

rails server

검증

웹브라우져를 열고 http://localhost:3000 를 열어보자.