• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Rocky Linux » How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

sammbysamm
October 16, 2023
Install Nginx on Rocky Linux 9

How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

Share on FacebookShare on LinkedinShare on Whatsapp

Setting up a web server is a crucial step in hosting websites and web applications. When it comes to web servers, Nginx is a top choice due to its speed, efficiency, and versatility. In this comprehensive guide, we’ll walk you through the entire process of how to install Nginx on Rocky Linux 9. Whether you’re an experienced system administrator or just starting with server management, we’ll provide clear instructions and explanations to ensure you get your web server up and running smoothly.

Table of Contents

  • Why Choose Nginx for Your Web Server?
  • Prerequisites
  • Install and Configure Nginx on Rocky Linux 9
    • Step 1: Updating Your System on Rocky Linux 9
    • Step 2: Installing Nginx on Rocky Linux 9
    • Step 3: Starting and Enabling Nginx on Rocky Linux 9
    • Step 4: Verifying Nginx Installation on Rocky Linux 9
    • Step 5: Configuring Firewall Rules on Rocky Linux 9
    • Step 6: Basic Nginx Configuration
  • Conclusion

Why Choose Nginx for Your Web Server?

Before we dive into the installation process, let’s understand why Nginx is a preferred choice for web servers:

OTHER POSTS

How To Install phpMyAdmin on Rocky Linux 9

How To Secure SSH with Fail2Ban on Rocky Linux 9

How To Install Rocky Linux 9.2 Server with Screenshots

  1. High Performance: Nginx is renowned for its exceptional speed and efficiency. It’s designed to handle a large number of simultaneous connections while utilizing minimal system resources, making it ideal for high-traffic websites.
  2. Resource Efficiency: Unlike some other web servers, Nginx is light on resource consumption. This implies that you can allocate more memory and CPU power to run your web applications.
  3. Versatility: Nginx doesn’t just serve static content; it can also act as a reverse proxy, load balancer, and more. Its versatility means it’s a great fit for many different purposes.
  4. Robust Security: Nginx offers robust security features, including support for SSL/TLS encryption, access control, and protection against various types of cyber threats like DDoS attacks.

Now that we understand the advantages of Nginx, let’s move on to the installation process.

Prerequisites

For Rocky Linux, make sure you’ve got a fresh installation of Rocky Linux 9 ready to go. You can set this up on either a physical machine or in a virtual environment like VMware or VirtualBox. To begin, follow our step-by-step guide:

  • Initial Setup Rocky Linux 9 Server: Secure and Efficient

Install and Configure Nginx on Rocky Linux 9

Here’s a simple guide on how to install and configure Nginx on Rocky Linux 9. By following these steps, you can tap into the advantages it offers:

Step 1: Updating Your System on Rocky Linux 9

Before installing any software on your Rocky Linux 9 system, it’s essential to ensure that your system is up to date. Open a terminal and run the following commands:

Bash
$ sudo dnf update
$ sudo dnf upgrade

When you execute these commands, they actively retrieve the most recent package information and subsequently ensure that your system’s software packages are updated to their latest versions available. Doing this on a regular basis is crucial to ensure the security and stability of your Rocky Linux 9 system.

Step 2: Installing Nginx on Rocky Linux 9

Rocky Linux 9 provides Nginx in its official repositories, which simplifies the installation process. You can install Nginx by running the following command:

Bash
$ sudo dnf install nginx

During the installation, Rocky Linux will download and installing Nginx along with any required dependencies. If you see a prompt, just type ‘y’ and hit Enter to confirm the action.

Step 3: Starting and Enabling Nginx on Rocky Linux 9

Now that Nginx is installed and ready on your Rocky Linux 9, you can start the Nginx service and configure it to launch automatically every time your system boots up. Use the following commands:

Bash
$ sudo systemctl start nginx
$ sudo systemctl enable nginx

These commands will initiate Nginx immediately and set it up to start automatically whenever your system starts up.

Step 4: Verifying Nginx Installation on Rocky Linux 9

To ensure that Nginx is running smoothly without any issues on your Rocky Linux 9, you can use the following command:

Bash
$ sudo systemctl status nginx

If Nginx is working properly, the status message will show that it is active and currently running. Another way to verify its status is by opening a web browser and entering your server’s IP address or domain name. If you see the default Nginx welcome page, your installation was successful on Rocky Linux 9.

Step 5: Configuring Firewall Rules on Rocky Linux 9

If you want people from the internet to access your Nginx web server, you need to configure your firewall to allow HTTP (port 80) and HTTPS (port 443) traffic on your Rocky Linux 9. The good news is that we can simplify this process by using the firewalld utility.

First, if firewalld isn’t already installed, you can install it by using the following command:

Bash
$ sudo dnf install firewalld

Once you’ve installed firewalld, enable it and permit HTTP and HTTPS traffic:

Bash
$ sudo systemctl start firewalld
$ sudo systemctl enable firewalld
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https
$ sudo firewall-cmd --reload

The commands mentioned above do a few important things. First, they activate the firewalld, then they include the HTTP and HTTPS services in its rules, and finally, they refresh the firewall settings to put these changes into action. This ensures that your web server allows external requests to reach your website without any issues.

Step 6: Basic Nginx Configuration

The configuration file of Nginx on Rocky Linux 9 are stored in the /etc/nginx directory. The primary configuration file is /etc/nginx/nginx.conf, while server-specific configurations are typically placed in /etc/nginx/conf.d/.

To create a basic server block configuration for your website, you can create a new file in the/etc/nginx/conf.d/ directory. For example:

Bash
$ sudo nano /etc/nginx/conf.d/mywebsite.conf

Inside this configuration file, you can define the server block for your website. Here’s a simple example suitable for a static website:

Nginx
server {
    listen 80;
    server_name mywebsite.com www.mywebsite.com;

    root /var/www/mywebsite;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

In this configuration:

  • We specify that the server should listen on port 80 (HTTP).
  • The server_name directive should be adjusted to match your actual domain.
  • The root directory is set to /var/www/mywebsite, where you should place your website’s files.
  • We define the default index file as index.html.
  • The location / block handles incoming requests, attempting to serve requested files and falling back to a 404 error if the file isn’t found.

After creating the configuration file, you can test it for syntax errors with the following command:

Bash
$ sudo nginx -t

If there are no errors, you can reload Nginx to apply the new configuration:

Bash
$ sudo systemctl reload nginx

Now that you’ve set up the fundamental Nginx configuration, your website should be accessible online.

Conclusion

Congratulations! You’ve successfully installing and configure Nginx on Rocky Linux 9, creating a solid foundation for hosting your websites or web applications. Nginx’s performance and versatility make it an excellent choice for serving web content.

However, remember that web server management is an ongoing process. Here are some additional steps to consider:

  • Implement SSL/TLS: Secure your website with HTTPS to protect user data and build trust.
  • Optimize Nginx: Fine-tune Nginx for better performance by configuring caching, compression, and load balancing.
  • Monitor and Maintain: Regularly monitor your server and keep its software up to date to ensure security and reliability.

By following these best practices and staying vigilant, you’ll help ensure the security and performance of your Rocky Linux 9 server running Nginx. Hosting your websites or applications has never been easier!

Also Read Our Other Guides :

  • How To Install Nginx on Debian 11: A Comprehensive Guide
  • How To Install Nginx on CentOS 7: A Comprehensive Guide
  • How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide
  • How To Build NGINX from Source (Compile) on Centos7
  • How To Build NGINX from Source (Compile) on Ubuntu Server 22.04
  • How To Build NGINX from Source (Compile) on Rocky Linux 9
  • How To Build NGINX from Source (Compile) on Debian 11

Hopefully, now you have learned how to install and configure Nginx on Rocky Linux 9 with a comprehensive guide.

Tags: NginxRocky LinuxWebserver

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

Next Post

Initial Setup CentOS 7 Server: Secure and Efficient

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install phpMyAdmin on Rocky Linux 9
Rocky Linux

How To Install phpMyAdmin on Rocky Linux 9

November 11, 2023
Secure SSH with Fail2Ban
Rocky Linux

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
Install Rocky Linux 9.2 Server
Rocky Linux

How To Install Rocky Linux 9.2 Server with Screenshots

October 20, 2023
setup Firewall Using Firewalld Rocky Linux 9
Rocky Linux

How To Set Up a Firewall Using FirewallD on Rocky Linux 9

October 18, 2023
Load More
Next Post
Initial Setup CentOS 7 Server

Initial Setup CentOS 7 Server: Secure and Efficient

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.