It's Me Syed
SYED SHAHZAIB
Full-Stack Software Engineer
  • Residence:
    United Arab Emirates
  • City:
    Sharjah
  • Age:
    33
English
Coding
Urdu
PHP
MySQL
Laravel
CodeIgniter
Wordpress
Html
CSS
Javascript
JQuery
React JS
Node JS
Typescript
Ant Design
Bootstrap
Git
CI/CD
Rest
MVC
OOP
PHP Unit
  • Android Native (Java)
  • Phonegap (Android & iOS)
  • Ubuntu/Cent OS
  • Amazon AWS (Ec2, S3, RDS)
  • Facebook SDK
  • Google SDK
  • Paypal SDK
  • Stripe SDK
  • Quickbooks SDK
  • DocuSign SDK

Beginners guide to install Nginx server

  • 2024-08-24 (1 month ago) |
  • Syed Shahzaib |
  • Linux Guide

Introduction

Nginx, pronounced "Engine-X," is an open-source web server that is highly recommended due to its usage as either a reverse proxy server, HTTP cache server, or as an HTTP server due to its flexible behavior. It is free and compatible with most of the Linux distributions. In this tutorial I will use AlmaLinux 9, previously known as CentOS, as we proceed.

Pre-Requisite

  1. Basic Linux knowledge.
  2. SSH access via terminal.

Step 1 - SSH into server

Log in to your web server using PuTTY on Windows or Terminal on Mac/Linux. Since I am using Windows, I will proceed with PuTTY.

install Nginx server using putty in windows

install Nginx server using putty in windows 2

Once you have completed all the steps shown in the images above. Click the Open button to start the PuTTY session.

install Nginx server using putty in windows 2

After clicking 'Open,' you will see a screen where you can enter your password. Type the password of your server and hit enter.

install Nginx server using putty in windows 2

Once you are logged in, you will see output like this in terminal/console.

Note: If your VPS is configured with a Private Key, you can attach it in PuTTY by navigating to Connection -> SSH -> Auth. Do not expand; just click. You will see an option to attach the Private Key file from your local system.

Step 2 - Installing NGINX server

Run the command: sudo dnf update to perform updates.

Run the command: sudo dnf install epel-release . This is the package that contain the repository configuration files for the EPEL repository. EPEL is a high-quality repository of open-source packages that maintain and run the Fedora project for RHEL, CentOS, and other compatible distributions.

Run the command: sudo dnf install nginx -y to start installing nginx server.

Run the command: sudo systemctl enable nginx to enable nginx as a service in OS.

Run the command: sudo systemctl start nginx to start nginx server.

Run the command: sudo systemctl status nginx to see the status of nginx server. The output should look like this:

install Nginx server using putty in windows 6

Optionally, run the command: sudo systemctl restart nginx to fully restart the nginx server. Or, run: sudo systemctl reload nginx to reload the Nginx configuration file..

Note: It is highly recommended to test your Nginx configuration file after making changes. Run sudo nginx -t to prevent breaking your server.

Hopefully, this article was helpful to you in setting up the Nginx Server on your Linux system. Stay tuned for more exciting content and tutorials.