DEV Community

Lê Vũ Huy
Lê Vũ Huy

Posted on • Updated on

Install NVM, Yarn, Postgres, Nginx, PM2 on Centos 8

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

5. Nginx

sudo yum install -y epel-release nginx
sudo systemctl start nginx
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Setup password for user postgres

sudo -u postgres psql
ALTER USER postgres with password 'yourpassword';
Enter fullscreen mode Exit fullscreen mode

Open port 5432 to connect database from remote:
nano /var/lib/pgsql/data/postgresql.conf

listen_addresses = '*'
port = 5432 
Enter fullscreen mode Exit fullscreen mode

Open firewall port:

firewall-cmd --zone=public --add-port=5432/tcp --permanent
firewall-cmd --reload
systemctl restart firewalld
Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

Restart postgres

sudo systemctl restart postgresql
Enter fullscreen mode Exit fullscreen mode

7. Unzip, git, pm2

yum install -y unzip git
npm i -g pm2
Enter fullscreen mode Exit fullscreen mode

Troubleshoot

If you got this error:

(13: Permission denied) while connecting to upstream
Enter fullscreen mode Exit fullscreen mode

Try to run this:

setsebool -P httpd_can_network_connect 1
Enter fullscreen mode Exit fullscreen mode

Top comments (0)