While working with a fresh CentOS 7.4 VM (specifically CentOS Linux release 7.4.1708), I hit a snag when trying to install DNF - the modern package manager meant to replace YUM. Standard installation methods failed unexpectedly:
# Standard approach that fails
sudo yum install epel-release
sudo yum install dnf
> No package dnf available
After enabling EPEL, a search reveals some DNF-related packages but not the main dnf package itself:
# yum search dnf
========================================================================= N/S matched: dnf ==========================================================================
dnf-langpacks.noarch : Langpacks plugin for dnf
dnf-langpacks-conf.noarch : Configuration file for DNF Langpacks plugin
etckeeper-dnf.noarch : DNF plugin for etckeeper support
python-dnf-langpacks.noarch : Langpacks plugin for dnf-2
mirrormanager2-mirrorlist.noarch : MirrorList serving mirrors to yum/dnf
The official DNF blog suggests using a Copr repository. While the configuration seems correct, it still doesn't work:
# Contents of /etc/yum.repos.d/dnf-stack-el7.repo
[dnf-stack-el7]
name=Copr repo for dnf-stack-el7 owned by @rpm-software-management
baseurl=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-stack-el7/epel-7-$basearch/
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-stack-el7/pubkey.gpg
enabled=1
enabled_metadata=1
After some digging, I found this sequence works reliably on CentOS 7.4:
# Clean up any existing EPEL config
sudo yum remove epel-release
# Install EPEL from official source
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Enable optional and extras channels
sudo yum-config-manager --enable extras
sudo yum-config-manager --enable Optional
# Install required dependencies first
sudo yum install python3 python3-rpm python3-dnf
# Finally install DNF
sudo yum install dnf --enablerepo=epel-testing
After successful installation, verify DNF is functioning:
# Check DNF version
dnf --version
# Test basic functionality
sudo dnf update
The issue stems from package dependencies shifting between CentOS 7.x versions. The standard EPEL repo contains DNF only for later 7.x releases. The solution:
- Forces a fresh EPEL installation
- Enables necessary channels that contain dependencies
- Installs Python 3 components first
- Uses epel-testing as a fallback
This approach has worked consistently across multiple CentOS 7.4 installations where standard methods failed.
Many developers assume installing DNF on CentOS 7.x should be straightforward:
sudo yum install epel-release
sudo yum install dnf
But when you hit No package dnf available
, it's time to dig deeper. Here's what I discovered troubleshooting this on CentOS 7.4.1708 (Core).
The EPEL repository for CentOS 7 doesn't actually contain the main dnf
package anymore - just some plugins like dnf-langpacks
. This explains why you only see these in search results:
yum search dnf
========================================================================= N/S matched: dnf ==========================================================================
dnf-langpacks.noarch : Langpacks plugin for dnf
dnf-langpacks-conf.noarch : Configuration file for DNF Langpacks plugin
etckeeper-dnf.noarch : DNF plugin for etckeeper support
python-dnf-langpacks.noarch : Langpacks plugin for dnf-2
mirrormanager2-mirrorlist.noarch : MirrorList serving mirrors to yum/dnf
After testing several approaches, here's the reliable method that worked:
# Install prerequisites
sudo yum install epel-release
sudo yum install python3 python3-devel python3-pip
# Add the RPM Software Management copr repository
sudo yum install yum-plugin-copr
sudo yum copr enable @rpm-software-management/dnf-stack-el7
# Install DNF and dependencies
sudo yum install dnf
# Verify installation
dnf --version
If the copr method fails, you can manually set up the repository:
sudo tee /etc/yum.repos.d/dnf-stack-el7.repo << 'EOF'
[dnf-stack-el7]
name=Copr repo for dnf-stack-el7
baseurl=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-stack-el7/epel-7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-stack-el7/pubkey.gpg
EOF
sudo yum clean all
sudo yum makecache
sudo yum install dnf
After successful installation, consider these optimizations:
# Set fastest mirror and parallel downloads
sudo tee /etc/dnf/dnf.conf << 'EOF'
[main]
fastestmirror=true
deltarpm=true
max_parallel_downloads=10
EOF
- If you get dependency errors, first run:
sudo yum install python3-*
- For SSL issues, update certificates:
sudo yum update ca-certificates
- Clear cache if packages appear missing:
sudo yum clean all
The key is using the correct repository since the standard EPEL no longer provides the main DNF package for CentOS 7.