How to Install Nginx on Rocky Linux 8

Install Nginx on Rocky Linux 8

In this article, we will have explained the necessary steps to install Nginx on Rocky Linux 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

The Nginx (short for Engine X) is a free, open-source, lightweight, and high-performance web server designed for high-traffic use cases. It is also acting as a popular Web server behind the Apache Web server and Microsoft’s IIS. Nginx is more resource-friendly than Apache. It can be served in front of other web servers as a reverse proxy.

Install Nginx on Rocky Linux 8

Step 1. First, before you start installing any package on your Rocky Linux server, we always recommend making sure that all system packages are updated.

sudo dnf update
sudo dnf upgrade

Step 2. Install Nginx on the Rocky Linux system.

Run the following command to install the Nginx web server on Rocky Linux:

sudo dnf install nginx

Output:

[[email protected] ~]# sudo dnf install nginx
Last metadata expiration check: 3:46:16 ago on Thu 17 Sept 2021 00:36:30 AM EDT.
Dependencies resolved.
================================================================================
 Package                     Arch   Version                     Repo       Size
================================================================================
Installing:
 nginx                       x86_64 1:1.21.1-9.module+el8.3.0+121+6327f1ce
                                                                appstream 566 k
Installing dependencies:
 dejavu-fonts-common         noarch 2.38-6.el8                  baseos     76 k
 dejavu-sans-fonts           noarch 2.38-6.el8                  baseos    1.4 M
 fontconfig                  x86_64 2.13.1-7.el8                baseos    293 k

To verify the Nginx version, use the following command to confirm:

nginx -v

Result:

[[email protected] ~]# nginx -v
nginx version: nginx/1.21.1

By default, Nginx does not come enabled and is deactivated on installation. To activate your Nginx service, use:

sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx

Step 3. Configure Firewall.

Now allow HTTP and HTTPS traffic (when using SSL) on the firewall:

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

Step 4. Verify the installation Nginx.

Now open a browser and enter server IP or domain name to see the Nginx default page on Rocky Linux.

That’s all you need to do to install Nginx on Rocky Linux 8. I hope you find this quick tip helpful. For further reading on the Nginx web server, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.