LoginSignup
1
1

More than 5 years have passed since last update.

ruby and rails and postgres-sql installation on ubuntu16.04

Last updated at Posted at 2017-07-25

結局、海外のサイトのほうが信頼性は高い。
自分用のメモ。
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04
https://gorails.com/setup/ubuntu/16.04
http://www.nokogiri.org/tutorials/installing_nokogiri.html

から抜粋。

rubyのインストール

sudo apt-get update
sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
rbenv install -l
rbenv install 2.X.X (choice yourself)
rbenv global 2.X.X 
rbenv versions

git関係

もし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

Hi ! You've successfully authenticated, but GitHub does not provide shell access.と出ればよし。

rails

gem search '^rails$' --all

インストール時にnokogiriでエラーが起きるので、先にnokogiriを整える。

sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev

postgres関係

bundle installでpgがエラーが出る可能性が高いので下も実行する。

sudo apt-get install libpq-dev

node.js関係

javascript runtime errorが出る可能性が高いので下も実行する。

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

本題のrails。searchした中で、自分のインストールしたいものを入れる。(今回は5.1.1を入れた)

gem install rails -v 5.1.1
rails new <your app> -d postgresql
bundle install 
sudo /etc/init.d/postgresql start
sudo -u postgres createuser <your name> -s
rails db:create
rails s

localhost:3000でページが見れれば終了。

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