How to Install Nginx on AlmaLinux 10

Published: 2026-06-26
Google AdSense 广告位 (待申请通过后开启)

Introduction

Nginx is a high-performance web server, reverse proxy, load balancer, and HTTP cache. It is widely used to host websites, serve static content, and proxy requests to backend applications.

This guide explains how to install Nginx on AlmaLinux 10, start the service, configure the firewall, and verify that the web server is working correctly.

Prerequisites

Before installing Nginx, ensure that:

* You are running AlmaLinux 10.

* You have sudo or root privileges.

* Your system is connected to the Internet.

Update System Packages

Update your system before installing Nginx:

sudo dnf update -y

Install Nginx

Install Nginx using DNF:

sudo dnf install nginx -y

After installation, verify the installed package:

rpm -q nginx

Enable and Start Nginx

Enable Nginx to start automatically after boot:

sudo systemctl enable nginx

Start the service:

sudo systemctl start nginx

Check the current status:

sudo systemctl status nginx

You should see that the service is **active (running)**.

Verify the Installation

Display the installed version:

nginx -v

Or display detailed build information:

nginx -V

Open your browser and visit:

http://YOUR_SERVER_IP

If everything is configured correctly, the default Nginx welcome page will be displayed.

Configure the Firewall

If firewalld is enabled, allow HTTP traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

For HTTPS support:

sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Verify the firewall rules:

sudo firewall-cmd --list-services

Common Nginx Commands

Start Nginx:

sudo systemctl start nginx

Stop Nginx:

sudo systemctl stop nginx

Restart Nginx:

sudo systemctl restart nginx

Reload the configuration:

sudo systemctl reload nginx

Disable automatic startup:

sudo systemctl disable nginx

Nginx Configuration Files

Main configuration file:

/etc/nginx/nginx.conf

Virtual host configuration directory:

/etc/nginx/conf.d/

Website document root:

/usr/share/nginx/html/

Log files:

/var/log/nginx/access.log
/var/log/nginx/error.log

Test the Configuration

Before reloading Nginx after editing configuration files, test the configuration:

sudo nginx -t

Example output:

syntax is ok
test is successful

Uninstall Nginx

Remove Nginx:

sudo dnf remove nginx -y

Verify removal:

nginx -v

If the command is no longer available, Nginx has been removed successfully.

Conclusion

Installing Nginx on AlmaLinux 10 is straightforward using the DNF package manager. After installation, remember to enable the service, allow HTTP and HTTPS through the firewall, verify the configuration with `nginx -t`, and monitor the log files when troubleshooting.

Related AlmaLinux 10 Tutorials

How to Install PostgreSQL on AlmaLinux 10

How to Install PHP Binaries on AlmaLinux 10

How to Compile Install PHP on AlmaLinux 10

Explore More

Technology Guides →

How to Enable Gzip Compression in Nginx

How to Configure Nginx FastCGI Cache for Better PHP Performance

How to Configure Nginx Reverse Proxy on AlmaLinux 10

Southeast Asia Insights →