Saturday, October 31, 2020

How to Install Nginx on RHEL 8 (Red Hat Enterprise Linux) Operating System

Must read

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...
SATISH KUMAR
I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
- Advertisement -

Nginx, the most popular open-source, HTTP and reverse proxy server with high-performance, use to handle the load of largest sites on the internet. We can use Nginx as a web server and as a reverse proxy for another web server like Apache.

If we compare Nginx and Apache, Nginx is capable of handling more number of concurrent connections.

- Advertisement -

In this tutorial article, we will learn how to install Nginx on RHEL 8 Operating System.

Prerequisites

Before starting the Nginx installation process, make sure you have a Red Hat 8 running system and a user to log in system with sudo privileges.

You should also make sure the other web server like apache not installed into the system and port 80 and 443 opened from outside.

Nginx install on Red Hat

To install high performance web server Nginx, you need to follow below steps: 

Step 1 – Enable EPEL repository 

- Advertisement -

The Nginx package is available in EPEL repository, So to install Nginx web server first need to install EPEL repository if it is not in your server.

To install EPEL repository type the below command in your terminal and press Enter.

$ sudo yum install epel-release

Step 2 – Install Nginx 

Once the EPEL repository installs in your system, you can install Nginx by using the following command:

- Advertisement -
$ sudo yum install nginx

Step 3 – Enable and start Nginx Service 

After successful installation of the Nginx web server, you should enable the Nginx service to make it auto-start on system start and start the Nginx service by using the following command:

$ sudo systemctl enable nginx
$ sudo systemctl start nginx

You can verify the Nginx service is running properly by checking the status of Nginx service, as shown below:

$ sudo systemctl status nginx

If service is running correctly you will get the screen with Active and running status as below image:

Step 4 – Configure Firewall for Port 80 and 443 

If your server’s firewall configured you should configure it for port http and https also so your web server reachable from the outside, to perform firewall configuration you should execute below command on terminal:

$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
$ sudo firewall-cmd --reload
Step 5 – Verify Nginx installation 
 
To verify Nginx web server is installed and running properly, you should open your serer IP into any web browser with typing address in the address bar like “http://YOUR_IP,” if you get the below screen means Nginx is running properly:
 

Nginx Services manage with systemctl

Red Hat Enterprise Linux (RHEL) 6 comes with systemctl to manage service; you can manage Nginx service with systemctl like below examples.

To stop the Nginx server, type below command:

$ sudo systemctl stop nginx

To start Nginx server use the following command:

$ sudo systemctl start nginx

To restart Nginx server run the below command:

$ sudo systemctl restart nginx

You can reload the Nginx server by using the following command:

$ sudo systemctl reload nginx

To disable Nginx service, so it not auto start on system boot, you can use below command:

$ sudo systemctl disable nginx

To re-enable Nginx service again type:

$ sudo systemctl enable nginx

Nginx important and configuration file structure

/etc/nginx/ is the leading directory of the Nginx server; all configuration files located here.

/etc/nginx/nginx.conf is the main configuration file of Nginx Server. Create new Nginx server block files with extension “.conf” and it is stored into /etc/nginx/conf.d/ directory.

Nginx server always read sites configuration from /etc/nginx/conf-d/ directories. It is recommended to make separate configuration files for each site to make changes quickly.

Nginx server’s log files saved with name “access.log” and “error.log” are located in the /var/log/nginx/ directory.

The website files you can store in any location and set the path into configuration files but commounly used webroot directories are below:

  • /var/www/<site_name>
  • /var/www/html/<site_name>
  • /usr/share/nginx/html
  • /home/<user_name>/<site_name>
  • /opt/<site_name>

Conclusion

Now you have learned how to install Nginx Web Server on RHEL 8. You are ready to deploy any website or application behind Nginx web server.

- Advertisement -
- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest article

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...

How to Reset the MySQL Root Password

Do you want to reset the MySQL root password? Sometimes we forget the root password and not able to log in on...