How to Install Nginx on AlmaLinux 10

By Chandrashekhar Fakirpure

Updated on Nov 21, 2025

In this tutorial, we'll learn how to install Nginx on AlmaLinux 10.

Introduction

This guide shows three practical installation options (package from distro, package from the official NGINX repo, and compiling from source) and the essential post-install steps: enable/service control, firewall rules, quick test, and SELinux adjustments where needed.

What is Nginx?

Nginx is a high-performance web server that also works as a reverse proxy, load balancer, and caching layer. We use it to handle large volumes of traffic efficiently, thanks to its event-driven architecture that manages thousands of concurrent connections with low resource usage. It delivers static files fast, routes requests to backend applications, protects services behind a reverse proxy, and helps scale infrastructure without adding unnecessary complexity.

Prerequisites

  • An AlmaLinux 10 dedicated server or VPS
  • SSH access and a non-root sudo user.
  • A domain name is optional but recommended if planning to serve public sites.
  • Basic familiarity with the shell.

How to Install Nginx on AlmaLinux 10

1. Update the system

Always start by updating package metadata and installed packages:

sudo dnf -y update
sudo dnf -y upgrade

(Keeping the system current avoids dependency and security surprises.)

2. Option A Install Nginx from the AlmaLinux

On AlmaLinux 10 the simplest path is the packaged nginx from the distribution repositories:

sudo dnf install -y nginx

Then enable and start the service:

sudo systemctl enable --now nginx
sudo systemctl status nginx --no-pager

This method installs a tested build that integrates with AlmaLinux system tools.

3. Option B Install from the official NGINX repository (stable or mainline)

If we want a specific NGINX stream (mainline or the official packages), add the official NGINX repo first and then install. 

Create /etc/yum.repos.d/nginx.repo with content like:

sudo vi /etc/yum.repos.d/nginx.repo

Add following content:

[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/rhel/10/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

Then:

sudo dnf makecache
sudo dnf install -y nginx
sudo systemctl enable --now nginx
sudo systemctl status nginx --no-pager

To switch to mainline (if needed):

sudo yum-config-manager --enable nginx-mainline
sudo dnf update nginx

When installing from the official repo, verify the GPG fingerprint on first import and accept only if it matches the published value. This is NGINX’s recommended method for getting upstream packages. 

4. Option C Build and install Nginx from source (when custom modules or build flags are required)

Only use this when we need custom compile options or third-party modules not available as packages. It required additional manual steps to do. So not recommended if you just want Nginx up and running. If you have any custom requirement and you know what you are doing, you can follow these steps.

Example minimal steps:

sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y pcre2 pcre2-devel zlib zlib-devel openssl openssl-devel wget

Download, extract, build

wget http://nginx.org/download/nginx-1.29.3.tar.gz
tar xzf nginx-1.29.3.tar.gz
cd nginx-1.29.3
./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf \
            --prefix=/etc/nginx --with-http_ssl_module
make
sudo make install

After source install, systemd unit and SELinux considerations need manual handling (packaged installs handle these automatically).

5. Open firewall ports (firewalld)

If firewalld is running, open HTTP/HTTPS:

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

If firewall is not used, skip this step.

6. SELinux notes (if SELinux is enforcing)

AlmaLinux enables SELinux by default in enforcing mode. If Nginx needs to make outgoing connections (for example as a reverse proxy or to fetch OCSP/Upstream), enable the relevant boolean(s):

Allow NGINX (httpd domain) to create outgoing network connections (proxy, upstream)

sudo setsebool -P httpd_can_network_connect 1

If Nginx needs to use nonstandard ports, register them with the http port type:

sudo semanage port -a -t http_port_t -p tcp 8080

Only enable booleans that are required for the planned architecture. Red Hat’s NGINX guidance recommends httpd_can_network_connect when NGINX proxies or makes outbound connections. 

7. Verify Nginx is running and serve a test page

Check Nginx version and status:

nginx -v
sudo systemctl status nginx --no-pager

Fetch the default page from localhost:

curl -I http://127.0.0.1
# or
curl -I http://localhost

Expected: HTTP/1.1 200 OK or similar. If not, check sudo journalctl -u nginx -n 50 and sudo nginx -t for config syntax errors.

8. Basic configuration pointers

Main config: /etc/nginx/nginx.conf

Virtual hosts (server blocks): /etc/nginx/conf.d/*.conf (packaged installs use this)

Test configuration before reload:

sudo nginx -t
sudo systemctl reload nginx

For PHP/FPM deployment, point fastcgi_pass to the FPM socket or TCP address and adjust SELinux booleans if needed.

A small, maintainable server block example (HTTP only):

sudo vi /etc/nginx/conf.d/example.com.conf

Add following content:

server {
    listen 80;
    server_name example.com www.example.com;

    root /usr/share/nginx/html/example;
    index index.html index.htm;

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

Save and exit the file.

After editing, run:

sudo nginx -t
sudo systemctl reload nginx

Create test web page

First we need to create a directory to host all the web pages:

sudo mkdir -p /usr/share/nginx/html/example

Now, create a simple index.html file:

sudo vi /usr/share/nginx/html/example/index.html

Add following code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Nginx Test Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            padding: 60px;
            background: #f5f5f5;
        }
        .box {
            background: white;
            padding: 40px;
            display: inline-block;
            border-radius: 8px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }
        h1 { margin-bottom: 10px; }
        p  { color: #555; }
    </style>
</head>
<body>
    <div class="box">
        <h1>Nginx is running</h1>
        <p>Your server is responding correctly.</p>
    </div>
</body>
</html>

9. Enable TLS (Let’s Encrypt) quick notes

To secure a site, we commonly use Certbot to obtain certificates and configure Nginx:

sudo dnf install -y certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com

Certbot will edit Nginx config (if using the packaged python3-certbot-nginx plugin) and set up auto-renewal. Test renewal with sudo certbot renew --dry-run.

10. Troubleshooting checklist (fast)

Config syntax test:

sudo nginx -t

Recent logs:

sudo journalctl -u nginx -n 200

Confirm process listening on port 80

sudo ss -lntp | grep :80

Verify firewall rules:

sudo firewall-cmd --list-all

Check SELinux mode

getenforce

If blocked, use ausearch -m avc -ts recent or sudo journalctl for AVC denials.

Best practice

Prefer packaged installs for ease of updates and systemd/SELinux integration. Use the official NGINX repo when needing newer upstream builds. 

Keep the server and NGINX updated with dnf update regularly.

Keep configuration in /etc/nginx/conf.d modular for easier management and backups.

Conclusion

Running Nginx on AlmaLinux 10 gives us a stable and efficient foundation for serving websites, APIs, and internal workloads. Once the service is installed, configured, and secured with the right firewall and SELinux rules, managing it becomes straightforward.

Keeping configurations modular, testing changes before reloads, and staying consistent with updates helps maintain long-term reliability. With this setup in place, we can build flexible, high-performance environments that handle traffic smoothly and remain easy to maintain as our infrastructure grows.

How to Install Nginx on AlmaLinux 10 - HostnExtra