回上一頁

ubuntu20.04 Deploy ROR+Nginx+Passenger

Ruby on Rails的完整佈署文件,隨時跟緊最新版本做更新文件。

Using Ruby Version Manager (RVM)

本人習慣使用rvm版本管理,若個人喜好可以自己研究其他Ruby版本管理工具,例如rbenv。

更新系統元件&Install NodeJS&ROR相關套件:


# 更新系統元件


  sudo apt updatex
gpg --keyserver hkp://pgp.mit.edu --recv-keys
409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io |
bash -s stable or curl -sSL https://get.rvm.io | bash
source ~/.rvm/scripts/rvm
rvm list known
rvm install ruby-3.0.0
gem install rails
Installing NGINX & Passenger:

NGINX(發音為”engine X”)是一個開源的高性能HTTP和反向代理服務器,以及一個郵件代理服務器。

它設計用於處理高流量的網站,提供快速、可靠和安全的網絡服務。

Passenger(也稱為Phusion Passenger)是一個開源的應用服務器,用於在Web伺服器(如Nginx或Apache)上運行Ruby、

Node.js和Python應用程式。它提供了一個高效且易於使用的方式來部署和管理應用程式。

# for ubuntu20.04 nginx passenger
sudo apt-get install -y dirmngr gnupg

# --recv-keys 561F9B9CAC40B2F7 & focal 指適用於20.04版本
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger focal main > 
/etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt install -y libnginx-mod-http-passenger
sudo ls /etc/nginx/conf.d/mod-http-passenger.conf
sudo service nginx restart
sudo /usr/bin/passenger-config validate-install
sudo /usr/sbin/passenger-memory-stats

sudo apt install nginx-core
sudo apt install nginx-extras
sudo apt install nginx-full
sudo apt install nginx-light
sudo apt install passenger
passenger-config validate-install

passenger-install-nginx-module
sudo apt install libcurl4-openssl-dev 
sudo apt install libcurl4-gnutls-dev

 

剩下完整資訊可從 medium看.