HomeLinux“Unable to find a match” Nginx Error & Fix

“Unable to find a match” Nginx Error & Fix

The error message indicating that there is “No match for argument: nginx Error Unable to find a match: nginx” suggests that the repository containing the Nginx package isn’t properly configured or enabled.

This tutorial will help you fix this issue and will allow you to install Nginx on your system.

Verify and Fix the Nginx Repository

Given the problem with loading the nginx.repo file, let’s ensure it’s properly configured and enabled. Open or edit nginx.repo file by executing the below command:

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

Ensure it contains the correct information for your Operating System version. Here’s an example configuration:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/$os/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

Make sure $os, $releasever and $basearch are correctly replaced with your OS name, OS version and architecture. If not, replace them manually with the correct values.

The $releasever and $basearch variables in repository configuration files are placeholders that dnf or yum replaces based on the running version of the operating system and the architecture of the hardware, respectively.

  1. $releasever: This represents the release version of the distribution. For example, in CentOS 8, $releasever would be replaced by 8.
  2. $basearch: This represents the architecture of your processor, such as x86_64 for 64-bit systems commonly used in desktops and servers, i386 for 32-bit systems, armhfp for ARM hard float, and others depending on the hardware.

If you want to determine what these values are set to on your system, you can manually check them using the dnf command:

echo "Release version: $(rpm -E %rhel)"
echo "Base architecture: $(uname -m)"

Example Output:

From the above example output, your OS release version is 7 and the architecture is x86_64. You can configure the nginx.repo file to use these values directly or allow the system to dynamically replace the $releasever and $basearch placeholders as usual.

Correct Permissions for Repo File

Make sure that the file has the appropriate permissions. You can set read permissions for the root user (which should be sufficient) with:

sudo chmod 644 /etc/yum.repos.d/nginx.repo

Import the GPG key for Repo

If GPG key is not present for the nginx repo, there will be still some errors when installing nginx. To avoid it, execute the following command to add the key:

sudo rpm --import https://nginx.org/keys/nginx_signing.key

Clean and rebuild the DNF cache

Cleaning and rebuilding the DNF cache can be an essential step in ensuring your package manager is working with the most current and consistent data. To do it before installing NGINX, execute:

sudo dnf clean all
sudo dnf makecache

Install NGINX

If the repo file is correctly configured as mentioned in this tutorial, you will be able to install nginx finally with the below command without any errors:

sudo dnf install nginx

Alternate Method

If setting up the Nginx repository directly continues to pose challenges, consider using the EPEL repository, which also contains the Nginx package, and then execute the Nginx install command:

sudo dnf install epel-release
sudo dnf install nginx

In this guide, we’ve successfully resolved the “No match for argument: nginx Error: Unable to find a match: nginx” error, which was preventing the installation of NGINX. Additionally, we’ve ensured that NGINX was installed correctly on the system. 🎉

Scroll to Top