Install NVM, Yarn, Postgres, Nginx, PM2 on Centos 8
Lê Vũ Huy
Posted on April 14, 2024
These are the quick commands to install NVM, Nodejs, Yarn, Nginx on Centos 8
1. NVM
sudo yum install curl tar nano -y
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm install 18
2. Yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg
sudo yum install yarn -y
5. Nginx
sudo yum install -y epel-release nginx
sudo systemctl start nginx
Config firewall
sudo yum install firewalld -y
sudo systemctl enable firewalld
sudo reboot
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
sudo systemctl enable nginx
6. PostgreSQL
Download:
sudo dnf module enable postgresql:13 -y
sudo dnf install postgresql-server -y
sudo postgresql-setup --initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql
Setup password for user postgres
sudo -u postgres psql
ALTER USER postgres with password 'yourpassword';
Open port 5432 to connect database from remote:
nano /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*'
port = 5432
Open firewall port:
firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld
Open this file: nano /var/lib/pgsql/data/pg_hba.conf
and add this line to end of file:
host all all 0.0.0.0/0 md5
host all all ::/0 md5
Restart postgres
sudo systemctl restart postgresql
7. Unzip, git, pm2
yum install -y unzip git
npm i -g pm2
Troubleshoot
If you got this error:
(13: Permission denied) while connecting to upstream
Try to run this:
setsebool -P httpd_can_network_connect 1
💖 💪 🙅 🚩
Lê Vũ Huy
Posted on April 14, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.