Search

How to Install Nginx on Rocky Linux 9

How to Install Nginx on Rocky Linux 9

Nginx is a powerful, lightweight web server that is widely used for serving static files, reverse proxying, and load balancing. This guide will show you how to install Nginx on Rocky Linux 9.

Prerequisites

  • A server running Rocky Linux 9
  • A user account with sudo privileges
  • Access to the terminal or SSH

Step 1: Update System Packages

Before installing any new package, it is good practice to update the system's package index. Open your terminal and run the following command:

sudo dnf update -y

Step 2: Install Nginx

Next, install Nginx by running the following command:

sudo dnf install nginx -y

Step 3: Start and Enable Nginx

Once the installation is complete, you need to start Nginx and enable it to run at boot time. Use the following commands:

sudo systemctl start nginx
sudo systemctl enable nginx

You can also check the status of the Nginx service to ensure that it is running properly:

sudo systemctl status nginx

Step 4: Configure Firewall

If you have a firewall enabled, you need to allow HTTP and HTTPS traffic. Use the following commands to open these ports:

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

Step 5: Verify Installation

To confirm that Nginx is installed and running properly, open your web browser and navigate to your server's IP address:

http://your_server_ip

You should see the default Nginx welcome page, which means that Nginx is successfully installed and running.

Conclusion

You've now successfully installed Nginx on your Rocky Linux 9 server. From here, you can start configuring Nginx to serve your web applications, set up virtual hosts, and much more. For additional configuration and optimization, refer to the official Nginx documentation.

Sys Admin

Sys Admin

I am a Red Hat Certified Engineer (RHCE) and working as an IT Professional since 2012...