Eric Guo's

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

Deploy next.js App to a Dedicateed Rocky Linux V8


Create a new user

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

Install Node.js 18 and Yarn

curl -sL -o
sudo bash
sudo dnf install -y nodejs
sudo yum install gcc-c++ make
curl -sL | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

From DigitalOcean blog

Fix permissions for the deploy folder

sudo mkdir /var/www
cd /var/www
sudo mkdir changelog
sudo chown changelog:changelog changelog/

Install other tools

sudo yum install git
sudo dnf update
sudo dnf install epel-release
sudo dnf install htop
echo 'machine login Eric-Guo password personal_token_here' >> ~/.netrc

Install PM2 & Nginx

sudo dnf install nginx
sudo npm install pm2@latest -g

Or alternatively install PM2 as system daemon

Copy Nginx configuration and disable firewall

cp /var/www/changelog/current/config/nginx/changelog.conf /etc/nginx/conf.d/
systemctl restart nginx
firewall-cmd --zone=public --add-service=https
firewall-cmd --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
systemctl restart firewalld