Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

Hardware

System: Rocky Linux RockyLinux 8.5 x64

  • Specs

    • 8 GB Memory

    • 4 AMD vCPUs

    • 160 GB Disk

  • Location

    • NYC

Server (hardware bound)

Host Name: rockylinux-s-4vcpu-8gb-amd-nyc3-01

  • IP(s):

    • ipv4: 159.xxx.xxx.184

  • Hardware link

  • Hardware provisioned (100%)

Service: Front-End

  • Name: openvinoapp

  • Static Front-end on Nginx server

    • Install Nginx on Rocky Linux 8

How to Install Nginx:

Step 1: Install Nginx on Rocky Linux 8

First, update all the available packages on Rocky Linux.

...

The output shows we have installed Nginx 1.14.1 version. The main configuration file is stored under the directory /etc/nginx and the main config file is /etc/nginx/nginx.conf. The Nginx log files are stored at /var/log/nginx.

Step 2: Setup Firewall

To allow HTTP and HTTPS traffic (when using SSL) on the firewall.

...

Code Block
$ sudo firewall-cmd --permanent --list-all

Step 3: Verify the installation

Open a browse and enter server IP or domain name to see the Nginx default page on Rocky Linux.

...

On Rocky Linux, the default Nginx webpage is located in /usr/share/nginx/html.

Uninstall Nginx

To completely uninstall Nginx on Rocky Linux, type

...

  • Configuration Location

    • /usr/share/nginx/html

  • Default TCP port: 80

Encrypt SSL for NGINX on Rocky Linux 8:

Step 1)  Install Certbot

The only step left is to install Let’s Encrypt and secure the Nginx webserver. However, to accomplish this, we need to install certbot. Written in Python and developed by the Electronic Frontier Foundation, Certbot is a fully featured client for the Let’s Encrypt CA. It is run on the webserver and allows you to automatically set up an SSL certificate for your webserver in a single command.

...

This installs certbot, certbot module for Nginx host of other packages and dependencies.

...

Step 2)  Install Let’s Encrypt SSL/TLS certificate

Finally, run the certbot client to install the SSL certificate

...

Click on the icon and then select ‘Certificate’.

...

This displays the certificate details as provided

...

Step 3) Managing the SSL certificate renewal

Let’s Encrypt certificate is valid for 90 days, however, Let’s encrypt recommends that you renew the certificate every 60 days. Email notifications will be sent to you the last 20 days to expiry with the frequency going up the last 10 days.

...

That’s all. Thank you for coming this far. We have demonstrated how you can install the Let’s Encrypt SSL certificate for Nginx on Rocky Linux 8.

Server Back-End

  • Name: ydiyoi-api

  • Backend API

  • Setting:

    • pm2 process

Install pm2:

Code Block
$ npm install pm2 -g

...

  • Default TCP port: 3000

  • Requires an active DB with the credentials

Server Database

  • Database system: Postgresql

Install PostgreSQL 14 on Rocky Linux 8

Step 1: System Update

Before you begin installing PostgreSQL 14 on Rocky Linux 8 | AlmaLinux 8 | CentOS 8, make the following updates to your system:

...

Reboot your system after the update:

Code Block
sudo reboot

Step 2: Add PostgreSQL Repository on Rocky Linux 8

PostgreSQL server 9.6, 10, 12 and 13 are included in the AppStream components.

...

Code Block
....
pgdg-redhat-repo-latest.noarch.rpm                                                                                                                             3.1 kB/s |  12 kB     00:03    
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                            Architecture                             Version                                      Repository                                      Size
===============================================================================================================================================================================================
Installing:
 pgdg-redhat-repo                                   noarch                                   42.0-20                                      @commandline                                    12 k

Transaction Summary
===============================================================================================================================================================================================
Install  1 Package

Total size: 12 k
Installed size: 12 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                       1/1 
  Installing       : pgdg-redhat-repo-42.0-20.noarch                                                                                                                                       1/1 
  Verifying        : pgdg-redhat-repo-42.0-20.noarch                                                                                                                                       1/1 
Installed products updated.

Installed:
  pgdg-redhat-repo-42.0-20.noarch                                                                                                                                                              

Complete!

Step 3: Install PostgreSQL 14 on Rocky Linux 8

Disable the default PostgreSQL module once the repository has been added:

...

Code Block
$ sudo dnf install -y postgresql14-server
Last metadata expiration check: 0:05:42 ago on Wed 27 Oct 2021 11:39:42 AM EDT.
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                              Architecture                            Version                                            Repository                               Size
===============================================================================================================================================================================================
Installing:
 postgresql14-server                                  x86_64                                  14.0-1PGDG.rhel8                                   pgdg14                                  5.7 M
Installing dependencies:
 postgresql14                                         x86_64                                  14.0-1PGDG.rhel8                                   pgdg14                                  1.5 M
 postgresql14-libs                                    x86_64                                  14.0-1PGDG.rhel8                                   pgdg14                                  274 k

Transaction Summary
===============================================================================================================================================================================================
Install  3 Packages

Total download size: 7.5 M
Installed size: 31 M

Step 4: Initialize and Start PostgreSQL 14 Database Service

Before running the service, you must first initialize the database instance after installing PostgreSQL 14:

...

Code Block
$ systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-10-27 13:06:30 EDT; 1min 11s ago
     Docs: https://www.postgresql.org/docs/14/static/
  Process: 7547 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 7552 (postmaster)
    Tasks: 8 (limit: 23547)
   Memory: 16.7M
   CGroup: /system.slice/postgresql-14.service
           ├─7552 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/
           ├─7554 postgres: logger 
           ├─7556 postgres: checkpointer 
           ├─7557 postgres: background writer 
           ├─7558 postgres: walwriter 
           ├─7559 postgres: autovacuum launcher 
           ├─7560 postgres: stats collector 
           └─7561 postgres: logical replication launcher 

Oct 27 13:06:30 localhost.localdomain systemd[1]: Starting PostgreSQL 14 database server...
Oct 27 13:06:30 localhost.localdomain postmaster[7552]: 2021-10-27 13:06:30.638 EDT [7552] LOG:  redirecting log output to logging collector process
Oct 27 13:06:30 localhost.localdomain postmaster[7552]: 2021-10-27 13:06:30.638 EDT [7552] HINT:  Future log output will appear in directory "log".
Oct 27 13:06:30 localhost.localdomain systemd[1]: Started PostgreSQL 14 database server.

Step 5: Connect to PostgreSQL 14 Database Locally

here are two methods to connect to a PostgreSQL 14 instance.

Method 1

Using sudo to run the Postgresql command directly.

Code Block
$ sudo -u postgres psql
psql (14.0)
Type "help" for help.

postgres=#

Method 2

To use this method, you must first switch to the Postgresql user created after installing PostgreSQL 14.

...

Code Block
$ psql
psql (14.0)
Type "help" for help.

postgres=#

Secure Postgres User

Now that you’re logged in as the postgres user, execute the following command to set a strong password for the default postgres user:

Code Block
$ psql -c "alter user postgres with password 'StrongPassword'"
ALTER ROLE

Create Database in PostgreSQL

Connect to PostgreSQL to create a database. When PostgreSQL is installed, a default user named ‘postgres‘ is created. Make a connection with this user first. Create database called testdb.

Code Block
# CREATE DATABASE testdb;
CREATE DATABASE

Create Tables in PostgreSQL

We’ll make a new table called Employees with the columns listed below:

...

Code Block
# DROP TABLE employees;
DROP TABLE

Step 6: Enable PostgreSQL Remote Access

You can update the configuration and set Listen address to your server IP address or “*” for all interfaces if you have applications that will connect to the server via the network.

...