[Rails] 專案部署前, 機器設定
1. update and upgrade system
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get autoremove
$ sudo reboot
2. set timezone
$ sudo dpkg-reconfigure tzdata
// 測試
$ date
3. install required package
sudo apt-get install curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs
4. install postgresql
$ sudo apt-get install postgresql postgresql-contrib
//測試
$ sudo -u postgres psql
//退出
\q
Ref: How To Install and Use PostgreSQL on Ubuntu 16.04
5. install git
$ sudo apt-get install git
6. install rbenv
$ sudo git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
// 修改 rbenv.sh
$ vim /etc/profile.d/rbenv.sh
加入
export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
// 設定權限
$ sudo chmod +x /etc/profile.d/rbenv.sh
無法 :wq (“rbenv.sh” E212: Can’t open file for writing)
Ref: vim error E212: Can’t open file for writing
7. install ruby-build
$ sudo git clone git://github.com/sstephenson/ruby-build.git /tmp/ruby-build
$ sudo /tmp/ruby-build/install.sh
8. install ruby
// 切換root
$ sudo su -
$ rbenv install 2.5.1
$ rbenv global 2.5.1
$ rbenv rehash
9. install image magick
$ sudo apt-get install imagemagick
10. install rails
$ gem install rails -v 5.2.2
$ rails -v
11. install nginx
$ sudo apt-get install nginx
12. deploy issue
bundler 版本機器上與 gemfile.lock 不符 gem install bundler -v ‘1.16.6’
postgresql Can’t find the ‘libpq-fe.h header
Ref: https://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem
master.key 要 linked_files , credentials 進版控 shared 手動建 master.key、database.yml
PG::ConnectionBad: FATAL: Peer authentication failed for user 'dd3’
p.s 改完之後要
/etc/init.d/postgresql reload
sudo service postgresql restart
13. install node
$ curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
$ sudo apt-get install -y nodejs
14. install yarn
$ npm install yarn -g
postgre sql
db 使用者認證 Ref: PG::ConnectionBad (FATAL: Peer authentication failed