If you’re looking to set up Nginx on Red Hat, Rocky Linux, AlmaLinux, or Oracle Linux, you’ve come to the right place! This guide provides easy, step-by-step instructions for both the stable and mainline versions of Nginx.
Step 1: Choose Your Version of Nginx
Nginx offers two primary versions:
- Stable Version: Suitable for production environments, offering a slower release cycle with fewer updates.
Latest Stable Version (as of today):1.26.2
- Mainline Version: Contains the latest features and bug fixes, ideal for testing or development environments.
Latest Mainline Version (as of today):1.27.1
Step 2: Install Prerequisites
Before installing Nginx, update your system packages:
Then, install the necessary dependencies:
Step 3: Set Up the Nginx Repository
For Stable Version:
To set up the repository for the stable version of Nginx, create a repository file:
For Mainline Version:
For the mainline version, use the following repository configuration:
Step 4: Install Nginx
With the repository set up, you can install Nginx. Run the following command:
Step 5: Start and Enable Nginx Service
To start Nginx and ensure it runs on system boot, execute:
Step 6: Verify the Installation
Check if Nginx is running properly:
You should see an output indicating that Nginx is active and running.
Step 7: Allow Nginx Through the Firewall
To make Nginx accessible, allow HTTP and HTTPS traffic through the firewall:
Step 8: Test Nginx
Open your web browser and navigate to your server’s IP address. If Nginx is correctly installed, you should see the default Nginx welcome page.
Conclusion
Congratulations! You have successfully installed Nginx on Red Hat, Rocky Linux, AlmaLinux, or Oracle Linux. Whether you chose the stable or mainline version, you now have a powerful web server up and running!