Eric Guo's

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

Install Rails 6 Stack in OpenAnolis Linux


OpenAnolis released as alternative distribute linux of CentOS. After got a server at Aliyun double 11 sales, I try to install my familiar Rails web framework on it.

I start installing the Linux server by do a system upgrade:

sudo yum update -y && sudo reboot

But install htop in Anolis linux is not as easy as CentOS, it’s require enable epel explicitly.

sudo yum config-manager --set-enabled PowerTools
sudo yum update
sudo yum --disablerepo="*" --enablerepo="epel" list available | grep htop
sudo yum --disablerepo="*" --enablerepo="epel" install htop

Install locale

yum install langpacks-en glibc-all-langpacks -y
localectl set-locale LANG=en_US.UTF-8

Create the deployer user

adduser deployer
sudo su - deployer
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys # and paste your public key
chmod 600 .ssh/authorized_keys

Enable deployer as sudo

sudo su -
cd /etc/sudoers.d/
echo "deployer ALL=(ALL) NOPASSWD:ALL" > 20-deployer-user

Secure the ssh by turn off root and password

sudo tail /etc/ssh/sshd_config

PermitRootLogin no
PasswordAuthentication no

Install memcached & redis

sudo yum install memcached
sudo systemctl enable memcached
sudo yum install redis
sudo systemctl enable redis

Install node.js 16 & yarn

rpm -q --whatprovides centos-release # get anolis-release-8.4-6.an8.x86_64
curl -fsSL >
# find & append anolis in below line
# if [[ $DISTRO_PKG =~ ^(redhat|centos|almalinux|rocky|cloudlinux|mageia|sl|anolis)- ]]; then
sudo bash ./
sudo yum install -y nodejs
sudo yum install gcc-c++ make
curl -sL | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

Install dependencies required by rbenv and Ruby

yum install openssl-devel readline-devel zlib-devel gdbm-devel git

Install rbenv and ruby-build in deployer user

cd # as a deployer
git clone .rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
~/.rbenv/bin/rbenv init # As an rbenv plugin
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
mkdir -p "$(rbenv root)"/plugins
git clone "$(rbenv root)"/plugins/ruby-build
git clone "$(rbenv root)"/plugins/rbenv-china-mirror

Install ruby 3.0.2

rbenv install -l
rbenv install 3.0.2
rbenv global 3.0.2
rbenv shell 3.0.2
echo "gem: --no-document" > ~/.gemrc
gem update --system

Create postgresql db user and import DB

sudo su - postgres
createuser deployer
CREATE DATABASE sccsa_production WITH ENCODING='UTF8' OWNER=deployer;
psql -d sccsa_production -f sccsa_postgres_db.sql

Install snapd

sudo dnf install epel-release
sudo dnf upgrade
sudo yum install bash-completion
sudo yum install policycoreutils-python-utils
sudo yum --disablerepo="*" --enablerepo="epel" install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install core; sudo snap refresh core

Install certbot

sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx