Eric Guo's blog.cloud-mes.com

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Install Rails Stack for Ubuntu 20.04

Permalink

Install nginx

sudo su -
cd /etc/apt/sources.list.d/
vi nginx.list
apt update

And paste the source:

nginx.list
deb https://nginx.org/packages/ubuntu/ focal nginx
deb-src https://nginx.org/packages/ubuntu/ focal nginx

And public keys:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ABF5BD827BD9BF62
apt update
apt-get install nginx
systemctl start nginx
systemctl enable nginx

It’s also possible to enable TLS 1.1/1.2 due to Ubuntu 20.04 not support by default.

/etc/nginx/nginx.conf
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
# seclevel for TLS 1.0 and 1.1
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:@SECLEVEL=1";

Install node.js 16 and yarn 1.x

Using nodesource distribution

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install gcc g++ make git
sudo apt-get install -y nodejs
## To install the Yarn package manager
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

Install rbenv

sudo su - # as root
apt update
apt install build-essential libgdbm-dev libncurses-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
logout # as ubuntu
# git clone https://github.com/rbenv/rbenv.git ~/.rbenv
git clone https://gitee.com/Eric-Guo/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
type rbenv
# git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
git clone https://gitee.com/Eric-Guo/ruby-build.git "$(rbenv root)"/plugins/ruby-build
# git clone https://github.com/andorchen/rbenv-china-mirror.git "$(rbenv root)"/plugins/rbenv-china-mirror
git clone https://gitee.com/Eric-Guo/rbenv-china-mirror.git "$(rbenv root)"/plugins/rbenv-china-mirror
rbenv install -l

Install ruby 3.2.1

sudo apt-get install libyaml-dev
rbenv install 3.2.1
rbenv global 3.2.1
echo "gem: --no-document" > ~/.gemrc
rbenv shell 3.2.1
gem update --system
gem install bundler
gem install bundler --default
gem install bundler

Install postgresql

apt-get install postgresql
apt-get install postgresql-server-dev-all
sudo su - postgres
createuser ubuntu
psql
ALTER ROLE ubuntu LOGIN;
CREATE DATABASE wefocusin_production WITH ENCODING='UTF8' OWNER=ubuntu;
logout
psql -d wefocusin_production -f wefocusin_production.sql

Install certbot

sudo apt install snapd
sudo snap install core
sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx

Comments