How to Install Nginx on Red Hat Enterprise Linux 9

How to Install Nginx on Red Hat Enterprise Linux 9

Nginx pronounced as ‘Engine X’ is a high-performance free and open-source server that can be used as a web server, reverse proxy, and load balancer. It was released in 2004 and can be installed macOS, Linux, Unix, Windows, and many other operating systems.

Nginx is like a gateway between the internet and your infrastructure. When you visit a web app, your request goes to the web server (Nginx), and it sends you the requested resource as a response. It is extremely popular with high-traffic sites because it can handle 10K requests simultaneously.

You can customize the behavior of Nginx server by using directives in the configuration file.

In today’s tutorial, we are installing Nginx on Red Hat Enterprise Linux 9.

Prerequisite

  • RHEL 9 instance
  • Root account or a user with sudo privileges

Install Nginx on Red Hat Enterprise Linux 9

Install Nginx package

Open up the terminal and run the below command to install Nginx on Red Hat Enterprise Linux 9.

sudo yum install nginx

Open the ports in Firewall

Run the below command to open the ports in the firewall. HTTP port 80 and HTTPS port 43 is used by Nginx.

sudo firewall-cmd --permanent --add-port={80/tcp,443/tcp}
sudo firewall-cmd --reload

Enable the Nginx service to run at boot

Enable the Nginx to automatically start at the boot time of system, run:

sudo systemctl enable nginx

Start the service

You can now start the Nginx service. In order to start Nginx, you should run:

sudo systemctl start nginx

Verify Nginx installation

Run the below command to verify if the Nginx package is installed or not.

sudo yum list installed nginx

Access the test page

In your favorite browser, type local host or 127.0.0.1 and hit Enter. A test page will be opened which shows Nginx is working properly.

Remove Nginx from Red Hat Enterprise Linux 9

If you wish to remove Nginx from Red Hat Enterprise Linux 9, you would run:

sudo yum remove nginx

Conclusion

We have successfully installed Nginx from Red Hat Enterprise Linux 9. We have also shown the removal method. Please hit like, share, and support Linux World.