Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Install NGINX on CentOS 8 by adding the official NGINX yum repository, refreshing DNF metadata, installing the nginx package, and checking the signing key before accepting it. The repository enables the stable channel by default; mainline is available as an explicit opt-in. After installation, start NGINX with sudo nginx and verify the local server with curl -I 127.0.0.1. A successful check begins with HTTP/1.1 200 OK.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
What you need before installing
This procedure uses the official NGINX package repository for RHEL-based systems. NGINX documentation lists CentOS alongside RHEL, Oracle Linux, AlmaLinux, and Rocky Linux for this installation method. You need a CentOS 8 machine with a working network connection, a user that can run sudo, and enough disk space for package metadata and the installed files.
As an Amazon Associate I earn from qualifying purchases.
- Confirm the operating system is CentOS 8.
- Confirm your account has sudo privileges.
- Make sure DNS and HTTPS access to
nginx.orgwork from the server. - Decide whether you need the conservative stable channel or deliberately want mainline packages.
The commands below use dnf, the normal successor to yum on CentOS 8. The equivalent package instruction is often written as sudo yum install nginx; DNF is the appropriate command name for this release.
Stable or mainline: which repository should you use?
The official repository publishes two channels. Stable is enabled in the repository file and is the sensible starting point for most production servers. Mainline is an optional channel for administrators who intentionally want newer NGINX releases and are prepared to test their applications, configuration, and modules against them.
#1 Best Overall
| Channel | Repository state in the official file | Operational choice | What to check |
|---|---|---|---|
| Stable | Enabled by default with enabled=1 |
Prefer when change is tightly controlled or the server is already in production | Existing configuration, dynamic modules, and application compatibility |
| Mainline | Disabled by default with enabled=0 |
Use only when you specifically need the mainline stream | Release freshness, module availability, upgrade behavior, and application testing |
The published repository configuration does not promise identical module or compatibility behavior for every deployment. Treat the channel as an operational decision: test it in your environment before putting a change into service. Enabling mainline does not install NGINX by itself; it changes which repository DNF can use for installation or later updates.
Add the official NGINX repository
Create /etc/yum.repos.d/nginx.repo as root. The following is the repository layout published by NGINX. It enables stable and defines mainline without enabling it.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=https://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
You can create the file with an editor, for example:
sudo vi /etc/yum.repos.d/nginx.repo
Paste the two stanzas exactly, save the file, and exit. The $releasever and $basearch variables are intentional: DNF substitutes the CentOS release and CPU architecture when it constructs the repository URL. Do not replace them with a guessed directory name.
Rank #2
The stable stanza points to https://nginx.org/packages/centos/$releasever/$basearch/. The optional mainline stanza points to https://nginx.org/packages/mainline/centos/$releasever/$basearch/. Both use GPG checking and the NGINX signing-key URL https://nginx.org/keys/nginx_signing.key.
Refresh metadata and install NGINX
Refresh package metadata before installing. This ensures DNF reads the repository definition you just added and has current package information.
-
Update repository metadata and installed packages:
sudo dnf update -
Install the NGINX package:
sudo dnf install nginx
DNF may ask for confirmation and may ask whether to import the repository signing key. Do not automatically accept that prompt; verify the key first as described below. If the package manager cannot reach the repository, stop and fix the repository or network problem rather than downloading an unrelated RPM from another source.
Verify the NGINX signing key before accepting it
GPG checking is enabled in both repository stanzas with gpgcheck=1. When DNF presents a signing-key prompt, inspect the fingerprint it displays and compare it character-for-character with the fingerprints published in the official NGINX installation guide. Accept the key only when the displayed fingerprint matches an official fingerprint.
- Read the complete fingerprint shown by DNF, including every hexadecimal character.
- Open the official NGINX installation guidance through a trusted administrative workstation or your approved documentation copy.
- Compare the two values exactly; do not rely on a shortened key ID or on the key’s display name alone.
- Decline the import if the fingerprint is missing, truncated, or different. Investigate DNS, HTTPS interception, repository-file changes, and the package-manager output before trying again.
- Accept the key only after the comparison succeeds, then allow DNF to continue the installation.
The key URL configured in the repository file is https://nginx.org/keys/nginx_signing.key. A URL by itself is not a substitute for checking the fingerprint presented by the package manager. The important control is the exact fingerprint comparison before trust is granted.
Install from the mainline channel instead
Leave the stable repository enabled unless you have a specific reason to use mainline. To enable mainline, run:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchsudo dnf config-manager --enable nginx-mainline
Then install NGINX in the usual way:
sudo dnf install nginx
Because the repository file sets stable to enabled=1 and mainline to enabled=0, the stable channel remains the published default. If you enable mainline intentionally, document that choice for future upgrades and test the resulting package set with your own configuration and module inventory. Mainline should not be selected merely because its name sounds newer; the relevant question is whether the newer release is compatible with the server’s workload and extensions.
Start NGINX and verify that it answers HTTP requests
After the package installation completes, start NGINX with:
Rank #4
sudo nginx
Perform a local HTTP header request from the same server:
curl -I 127.0.0.1
A successful default response begins with:
HTTP/1.1 200 OK
The -I option requests headers rather than downloading the response body. Using 127.0.0.1 tests the local listener and avoids involving external DNS, a load balancer, or an Internet firewall. If you receive the expected status line, the installed NGINX process is serving the local default response.
Recommended Free Tools
A non-200 response still provides useful evidence: it means the request reached an HTTP listener, but the configured response or request path needs investigation. If the connection is refused or times out locally, move to the troubleshooting checks below instead of assuming the package installation failed.
Know the important files and paths
The default main configuration file is:
/etc/nginx/nginx.conf
NGINX writes its standard logs under:
/var/log/nginx/
The two primary log files are:
/var/log/nginx/access.log— records requests received by NGINX./var/log/nginx/error.log— records startup, configuration, connection, and runtime errors.
When a package has been built with paths that differ from the defaults, inspect its compiled configuration arguments:
Best Value
nginx -V 2>&1 | awk -F: '/configure arguments/ {print $2}' | xargs -n1
This is especially useful when a command appears to succeed but the expected configuration or log file is empty. The output identifies compiled path choices so you can locate the files the installed binary actually uses.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Install a packaged dynamic module
If your configuration requires a dynamic module supplied as an NGINX package, install it by replacing <NAME> with the module’s package name:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
sudo dnf install nginx-module-<NAME>
Module availability can differ between repository channels and package builds. Check the selected channel before assuming a module exists, and test the module with the exact NGINX version you intend to run. A module compiled for a different package set can prevent NGINX from loading its configuration, so treat module installation as part of the same compatibility test as the core package.
Troubleshoot common installation and startup problems
DNF cannot find the repository or package
- Check that
/etc/yum.repos.d/nginx.repoexists and contains both stanzas without spelling errors. - Confirm that the stable stanza has
enabled=1. If only the mainline stanza is enabled, verify that you intentionally selected it. - Check network and DNS access to the exact
baseurlin the file. - Run
sudo dnf updateagain after correcting the file so metadata is refreshed.
The signing-key fingerprint does not match
Decline the key import. Do not bypass GPG checking or replace the configured key URL with an unverified copy. Recheck the repository file, the connection to NGINX’s key endpoint, and the authoritative fingerprint in the NGINX installation guidance. A mismatch is a trust failure, not a prompt to choose a different answer.
sudo nginx returns an error
- Read
/var/log/nginx/error.logfor the reported path, permission, or module problem. - Confirm that the configuration being read is
/etc/nginx/nginx.conf, unlessnginx -Vshows a different compiled path. - If you recently installed a dynamic module, verify that its package belongs to the same repository channel and NGINX package set.
curl -I 127.0.0.1 cannot connect
- Check the error log for startup failures.
- Use the compiled-path command to find a non-default error log if
/var/log/nginx/error.loghas no relevant entry. - Run
sudo nginxagain after correcting the reported configuration or module issue, then repeat the local curl check.
The local response is not HTTP/1.1 200 OK
The request reached an HTTP service, but the returned status is not the documented default response. Review the active configuration and the access and error logs. If the package came from a different channel than intended, confirm repository enablement before making configuration changes.
Open Source NGINX versus NGINX Plus
The repository and commands in this guide install NGINX Open Source packages. NGINX Plus is a separately licensed product with its own repository and credentials. Only administrators who already have an NGINX Plus subscription should follow Plus-specific distribution instructions; adding the Open Source repository does not install or convert a server to NGINX Plus.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesQuick Recap
Installation checklist
- CentOS 8 and sudo access confirmed.
/etc/yum.repos.d/nginx.repocreated with stable enabled and mainline disabled unless deliberately selected.- Repository metadata refreshed with
sudo dnf update. - Signing-key fingerprint compared with the official NGINX documentation before acceptance.
- NGINX installed with
sudo dnf install nginx. - Server started with
sudo nginx. curl -I 127.0.0.1returns a response beginning withHTTP/1.1 200 OK.- Configuration and logs located at their expected paths, or verified with
nginx -Vwhen a package uses different paths.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




