How to install WP-CLI on CentOS, Fedora, or Red Hat

Installing WP-CLI on CentOS, Fedora, or Red Hat provides a reliable command-line path for routine WordPress administration. The wp command is useful for site URL updates, content maintenance, plugin changes, cache flushes, and scripted operational tasks that are awkward to repeat through the browser.

The verified install path uses the official WP-CLI Phar build instead of relying on distro package availability. That keeps the installation method consistent across Fedora and RHEL-family systems, where package names and repositories can differ more than the PHP CLI runtime requirements.

The command itself does not require a web server restart, but it should be executed from the correct WordPress directory and under an account that can read the site files. A successful wp --info check confirms that WP-CLI is installed; some subcommands still depend on extra tools such as mysqldump or on valid database credentials in /wp-config.php/.

Steps to install WP-CLI on CentOS, Fedora, or Red Hat:

  1. Install the command-line prerequisites for WP-CLI.
    $ sudo dnf install --assumeyes ca-certificates curl php-cli less
    Updating and loading repositories:
    ##### snipped #####
    Complete!

    The verified Fedora 42 test environment installed php-cli 8.4.19.

  2. Download the official WP-CLI Phar build.
    $ curl -sSLO https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
  3. Make the downloaded Phar executable.
    $ chmod +x wp-cli.phar
  4. Move the executable into a directory on the default command path.
    $ sudo mv wp-cli.phar /usr/local/bin/wp
  5. Verify the wp command is available system-wide.
    $ wp --info
    OS:	Linux 6.12.72-linuxkit #1 SMP Wed Feb 25 13:21:17 UTC 2026 aarch64
    Shell:
    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

    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.

  6. Change into the WordPress document root before running site-specific commands.
    $ cd /var/www/html

    Use the directory that contains /wp-config.php/ for the site that the wp command should manage.