Installing WP-CLI on current dnf-based CentOS Stream, Fedora, and Red Hat-style hosts makes repetitive WordPress administration faster and more predictable than repeating the same work through the dashboard. The wp command is especially useful for backups, URL updates, plugin maintenance, and controlled recovery work when shell access is already part of the operating model.
WP-CLI is distributed upstream as a single Phar archive that runs on the host PHP CLI binary and reads site context from the directory that contains wp-config.php. That upstream Phar stays the cleanest cross-distro path here because current Fedora repositories still ship an older packaged wp-cli build, while current RHEL 9-style base repositories do not provide one consistent package path at all.
Examples below target current dnf-based releases, not legacy yum-only systems. Install and run the command as an account that can read the WordPress files, and treat wp --info as proof that the CLI itself is installed rather than proof that every site-aware subcommand is ready. Database-aware commands still depend on the matching PHP MySQL extension, and commands such as wp db export still rely on host tools like mysqldump.
Steps to install WP-CLI on CentOS, Fedora, or Red Hat:
- Install the PHP CLI runtime and the support packages needed for current WP-CLI use.
$ sudo dnf install --assumeyes ca-certificates curl php-cli php-mysqlnd less Updating and loading repositories: ##### snipped ##### Complete!
The verified Fedora 42 environment used php-cli 8.4.19. Keep php-mysqlnd in the baseline so database-aware wp commands can talk to the local WordPress database instead of stopping at a missing MySQL extension error.
On minimal RHEL-style images that already provide curl-minimal, replace curl with curl-minimal in the install command to avoid a package conflict while keeping the same curl binary available.
- Download the official WP-CLI Phar build.
$ curl -fsSLO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
The upstream WP-CLI project still recommends the Phar install method for most users, which avoids distro-package drift across current Fedora and RHEL-family hosts.
- Confirm the downloaded Phar runs correctly with the host PHP binary before moving it into the command path.
$ php wp-cli.phar --info OS: Linux 6.12.76-linuxkit #1 SMP Fri Mar 6 10:10:19 UTC 2026 aarch64 PHP binary: /usr/bin/php PHP version: 8.4.19 php.ini used: /etc/php.ini WP_CLI phar path: phar:///wp-cli.phar WP-CLI version: 2.12.0
If this step fails, fix the host PHP CLI installation first instead of moving a broken Phar into PATH.
- Make the downloaded Phar executable.
$ chmod +x wp-cli.phar
- Move the executable into a standard system-wide command path as wp.
$ sudo mv wp-cli.phar /usr/local/bin/wp
Keep the filename as exactly wp so later examples, shell completion, and automation can use the default command name.
- Verify that the final wp command is available system-wide.
$ wp --info OS: Linux 6.12.76-linuxkit #1 SMP Fri Mar 6 10:10:19 UTC 2026 aarch64 PHP binary: /usr/bin/php PHP version: 8.4.19 php.ini used: /etc/php.ini WP_CLI phar path: phar:///usr/local/bin/wp WP-CLI version: 2.12.0
The upstream Phar is the stronger default here because current Fedora repositories still expose an older wp-cli package, while current RHEL 9-style base repositories may not list wp-cli at all.
If the shell still reports wp: command not found, confirm that /usr/local/bin is in the active PATH and that the file was moved as wp instead of being left as wp-cli.phar.
- Change into the exact WordPress document root before using site-specific wp commands.
$ cd /var/www/example.com/public_html
Use the directory that contains the active wp-config.php file for the target site.
wp --info proves the CLI is installed, but database-aware commands still rely on the host WordPress runtime and tools such as mysqldump for backup-related operations.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
