Free tools Windows power users keep installed
One-click scans. No signup required.
Install the open-source NGINX package on CentOS 8 by adding NGINX’s official yum repository, refreshing metadata, importing and checking the repository signing key, and installing with dnf. The stable channel is enabled by default; the mainline channel is available but opt-in. After installation, start the server with sudo nginx and verify it locally with curl -I 127.0.0.1.
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
This procedure follows NGINX’s repository method for RHEL-based systems, a method the vendor recommends for production environments. You need a CentOS 8 host with sudo access and outbound access to the repository.
As an Amazon Associate I earn from qualifying purchases.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteWhat you will install
The procedure installs NGINX Open Source from the official NGINX package repository rather than from an arbitrary third-party build. CentOS is treated as a RHEL-based operating system in NGINX’s installation guidance, so the repository format uses yum/dnf conventions and the CentOS release and architecture variables.
The repository definition contains two channels:
- Stable: enabled by default and intended for a more conservative production update path.
- Mainline: disabled by default and enabled only when you deliberately choose the newer development line.
Both channels use GPG signature checking. Your package manager may ask to import the NGINX signing key during the first installation or repository refresh. Do not accept a key until its complete fingerprint matches the fingerprint published in the current NGINX installation guide.
#1 Best Overall
Check prerequisites before changing the system
Confirm the operating system
Run the following command and make sure the machine is the CentOS 8 system you intend to modify:
cat /etc/centos-release
The repository URL uses $releasever, so a host reporting a different major release will resolve to a different repository path. Do not copy a CentOS 8 repository file onto another major release without adapting and validating it.
Confirm administrative access
Most installation commands need root privileges. Check that your account can use sudo:
sudo -v
If sudo is not configured, have an administrator perform the steps or grant the minimum required administrative access. You also need network connectivity to nginx.org; a firewall, proxy, or DNS policy that blocks the repository will prevent metadata downloads.
Decide which release channel you need
Use stable unless you have a specific reason to test or deploy mainline packages. Consider your application’s compatibility, the modules you require, and how quickly you want new NGINX changes. The repository file can define both channels while keeping mainline disabled, allowing an intentional switch later.
Create the official NGINX repository file
Create /etc/yum.repos.d/nginx.repo as root. The following is the repository layout published by NGINX:
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #2
sudo tee /etc/yum.repos.d/nginx.repo >/dev/null <<'EOF'
[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
EOF
The single quotes around EOF are intentional: they stop the shell from expanding $releasever and $basearch while the file is being created. DNF substitutes those variables when it reads the repository definition.
Review the file before proceeding:
sudo sed -n '1,120p' /etc/yum.repos.d/nginx.repo
Check that nginx-stable has enabled=1, nginx-mainline has enabled=0, GPG checking is enabled in both sections, and both sections reference the NGINX signing-key URL. Keeping mainline disabled avoids an accidental channel change during a routine update.
Refresh metadata and install NGINX
Update repository metadata
Refresh package metadata before installing. On CentOS 8, dnf is the normal successor to yum:
sudo dnf update
This command downloads current metadata and may update installed packages. Read the transaction summary and approve it only if the proposed updates are acceptable for the machine. If you want to refresh metadata without applying unrelated package updates, use your organization’s normal DNF metadata workflow, then continue with the install command.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Install the package from stable
sudo dnf install nginx
DNF should show the package source and the signing-key prompt when the key is not already trusted. The equivalent command documented on the official package page is sudo yum install nginx; on CentOS 8, the DNF form is the usual choice and uses the same repository configuration.
Choose mainline deliberately, if required
If you have tested mainline and intentionally need it, enable that repository before installing or updating:
sudo dnf config-manager --enable nginx-mainline
After enabling it, inspect the transaction that DNF proposes. Stable remains the default in the published configuration, but enabling mainline changes which repository can provide NGINX packages. If you later decide to return to stable, disable mainline and enable stable explicitly:
sudo dnf config-manager --disable nginx-mainline
sudo dnf config-manager --enable nginx-stable
Test the resulting package selection in a staging system before changing a production host. The official guidance does not promise identical module or application compatibility for every deployment.
Verify the NGINX signing key safely
GPG verification protects you from installing a package whose signature does not match the repository’s trusted key. The repository has gpgcheck=1 and points to https://nginx.org/keys/nginx_signing.key.
- When DNF asks whether to import a key, pause at the prompt rather than accepting automatically.
- Record the complete fingerprint displayed by the package manager. Do not rely on a shortened key ID.
- Compare every fingerprint character with the fingerprints published in NGINX’s current installation guide, using an independently obtained copy of that guide if your environment requires out-of-band verification.
- Accept the key only when the fingerprint matches exactly. If it differs, answer no, stop the installation, and investigate DNS, proxy interception, repository configuration, or a possible man-in-the-middle condition.
A successful key check does not replace ordinary change control. Keep the repository URL, the date of the verification, and the selected channel in your system records so another administrator can reproduce the decision.
Start NGINX and verify that it serves HTTP
Start the server with:
sudo nginx
Then make a request to the loopback address:
curl -I 127.0.0.1
A working default server should return headers beginning with HTTP/1.1 200 OK. The -I option requests headers only, so this is a quick local check that NGINX accepted its configuration, bound to the HTTP listener, and returned a response.
If you need to stop the process while troubleshooting, use the NGINX control command appropriate to your package and configuration rather than killing an arbitrary process. Before any reload or restart, validate the configuration syntax:
Rank #4
sudo nginx -t
A successful test reports that the syntax is okay and the test is successful. Treat any error as a deployment blocker: fix the named file and line, run the test again, and only then reload or restart.
Know the important files and paths
Main configuration
The default main configuration file is:
/etc/nginx/nginx.conf
Read it before making changes so you understand which server blocks and include directives are active. Keep a backup of the original file and make one logical change at a time. After editing, run sudo nginx -t and keep the command output with your change record.
Access and error logs
NGINX writes logs under:
/var/log/nginx/
The standard files are:
/var/log/nginx/access.logfor requests that reach NGINX./var/log/nginx/error.logfor startup, configuration, connection, and upstream errors.
When a request fails, inspect the error log at the same time as you repeat the request. Correlating the timestamp and request path is more reliable than guessing from the browser’s error page.
Discover compiled paths when a package differs
Packages can be built with different compile-time defaults. Inspect the configure arguments with:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
nginx -V 2>&1 | awk -F: '/configure arguments/ {print $2}' | xargs -n1
Use the resulting paths to locate the active configuration, module directory, PID file, and log locations when they do not match the defaults above. This is especially useful after replacing a distribution package, installing a custom build, or troubleshooting a host that has more than one NGINX installation.
Stable versus mainline: which repository should you enable?
| Decision factor | Stable channel | Mainline channel |
|---|---|---|
| Repository state in the published file | Enabled by default (enabled=1) |
Disabled by default (enabled=0) |
| Release posture | More conservative choice for routine production operations | Newer line that you opt into deliberately |
| How to select it | Leave nginx-stable enabled |
Run sudo dnf config-manager --enable nginx-mainline |
| Compatibility expectation | Still test your application and modules before rollout | Test especially carefully with your application and module set |
| Rollback planning | Keep package and configuration backups | Plan a tested path back to stable before enabling it |
“Stable” does not mean that every application or third-party module will behave identically across updates, and “mainline” is not a guarantee of a feature your application needs. Choose based on the versions your application supports, the modules you depend on, your maintenance window, and your ability to test. Keep all hosts in a service tier on the same channel unless you have a documented reason to mix them.
Best Value
Install a packaged dynamic module
If your deployment needs a module supplied as a separate NGINX package, install it by name:
sudo dnf install nginx-module-<NAME>
Replace <NAME> with the module name available in the selected repository. Do not assume that a module built for one NGINX release line is compatible with another. After installing a module, check the active configuration for its load directive, run sudo nginx -t, and perform the same local HTTP check. If the module is not found, confirm that you selected the repository channel that publishes it and inspect the package’s compiled module paths with nginx -V.
Troubleshoot common installation and startup failures
DNF cannot find the nginx package
- Display the repository file and verify the section name, URL, and
enabledvalue. - Run
sudo dnf updateagain to refresh metadata. - Check that
$releaseverand$basearchresolve to a repository path that exists for the host. - Check DNS, proxy, and firewall access to
nginx.org.
Do not work around a missing package by downloading an unrelated RPM from an unverified source. Correct the repository or network problem first.
The key fingerprint does not match
Decline the import. Recheck that you are using the official key URL, compare the full fingerprint with the current NGINX documentation, and investigate any TLS-inspecting proxy or DNS anomaly. A mismatch is a trust failure, not an invitation to proceed with --nogpgcheck.
Port 80 is already in use
If sudo nginx fails because it cannot bind the HTTP port, identify the service already listening on that port and decide which service should own it. Do not blindly stop a production service. If NGINX should use another listener, change the relevant listen directive in the active server configuration, validate with sudo nginx -t, and repeat the local check against the chosen port.
The configuration test fails
Read the exact filename and line number in the error. Typical causes include a missing semicolon, a typo in a directive, an include file that does not exist, or a module directive without the corresponding module package. Correct one issue at a time, rerun sudo nginx -t, and do not reload until it reports success.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows 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 reinstallcurl -I 127.0.0.1 returns connection refused
- Run
sudo nginx -tto rule out a configuration problem. - Run
sudo nginxand watch for an error message. - Inspect
/var/log/nginx/error.logfor bind, permission, or include errors. - Use the paths reported by
nginx -Vif the log is not under/var/log/nginx/.
If NGINX starts but a remote client cannot connect, separate the local application check from network policy: first make the loopback request succeed, then examine the host firewall, cloud security rules, load balancer, and DNS.
The response is not HTTP 200
A non-200 status can be valid for a custom configuration, but it may indicate that your server block is not the one you expected. Inspect /etc/nginx/nginx.conf and its included files, confirm the request’s host and port, and correlate the request with access.log and error.log. The documented default verification result is a response beginning with HTTP/1.1 200 OK; deviations should be explained by an intentional configuration.
After the first successful response
- Save a copy of
/etc/nginx/nginx.confand record the repository channel you selected. - Review the access and error log locations and make sure your log collection or rotation policy covers them.
- Define your server blocks and content or reverse-proxy targets in a controlled change, rather than editing several unrelated settings at once.
- Run
sudo nginx -tfor every configuration change. - Use a local
curl -I 127.0.0.1check after starting or reloading, then test the real hostname and application path from an appropriate client. - Keep stable and mainline decisions consistent across a service tier, and test module updates before production deployment.
When NGINX Plus is relevant
NGINX Plus is a separately licensed product with its own repository and credentials. The repository file and commands in this guide install NGINX Open Source; they do not install NGINX Plus. Use the Plus procedure only when your organization has an NGINX Plus subscription and the required repository credentials.
Quick Recap
CentOS 8 installation checklist
- CentOS 8 is confirmed and the account has sudo privileges.
/etc/yum.repos.d/nginx.repocontains the official stable and optional mainline sections.- Stable is enabled unless mainline was an explicit, tested choice.
sudo dnf updatecompleted andsudo dnf install nginxselected the intended repository.- The GPG fingerprint was compared in full with NGINX’s published fingerprint before key acceptance.
sudo nginxstarts the server.curl -I 127.0.0.1returns the expected local response, normally beginning withHTTP/1.1 200 OK.- Configuration, logs, module paths, and any deviations from defaults are documented.
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.




