Install WP-CLI to manage WordPress on Rocky Linux 10

By Anurag Singh

Updated on Dec 24, 2025

Install WP-CLI to manage WordPress on Rocky Linux 10

In this tutorials, we'll explain how to install WP-CLI to manage WordPress site on Rocky Linux 10.

Intruduction

WP-CLI (WordPress Command Line Interface) is a powerful, lightning-fast tool designed to manage your WordPress site directly from your hosting server’s terminal. It allows you to perform routine tasks quickly, reliably, and without needing to log in through a web browser.

In this guide, we'll walk you through the installation and practical usage of WP-CLI on your hosting account. Let's dive in!

Let's get started!

Prerequisites

Before proceeding, make sure you have the following in place:

  • A Fresh Rocky Linux 10 dedicated server or KVM VPS.
  • Root or Sudo Privileges: You should have sudo privileges to install packages and make system-wide changes.
  • A Valid Domain Name (Optional but Recommended)
  • Replace example.com with your domain name.

Learn how to install WP-CLI to manage WordPress site on Rocky Linux 10.

1. Install Required Packages

sudo dnf update

sudo dnf install -y nginx mariadb-server php-fpm php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip unzip curl certbot python3-certbot-nginx

Check PHP version:

php -v

2. Setup Database

sudo mysql_secure_installation

Login into MariaDB:

sudo mariadb

Create database:

CREATE DATABASE newsite;
CREATE USER 'newsiteuser'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
GRANT ALL PRIVILEGES ON newsite.* TO 'newsiteuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

3. Install WP-CLI

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Test:

wp --info

Similar output you will get:

OS:    Linux 6.12.0-124.20.1.el10_1.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Dec 12 13:44:12 UTC 2025 x86_64
Shell:    /bin/bash
PHP binary:    /usr/bin/php
PHP version:    8.3.26
php.ini used:    /etc/php.ini
MySQL binary:    /usr/bin/mariadb
MySQL version:    mariadb  Ver 15.1 Distrib 10.11.11-MariaDB, for Linux (x86_64) using  EditLine wrapper
SQL modes:    STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:    phar://wp-cli.phar/vendor
WP_CLI phar path:    phar:///usr/local/bin/wp
WP-CLI packages dir:    
WP-CLI cache dir:    /root/.wp-cli/cache
WP-CLI global config:    
WP-CLI project config:    
WP-CLI version:    2.12.0

4. Download & Configure WordPress

sudo mkdir -p /var/www/newsite
sudo chown -R $USER:$USER /var/www/newsite
cd /var/www/newsite

Note: $USER:$USER replace it with your normal user if you are logged in as root.

If you are a root user, you need to switch to normal user with administrative privileges using su - <username> command.

Now download: 

wp core download
wp config create --dbname=newsite --dbuser=newsiteuser --dbpass=StrongPasswordHere

Install WordPress:

wp core install \
  --url="http://example.com" \
  --title="My WordPress Site" \
  --admin_user=admin \
  --admin_password=StrongAdminPassword \
  --admin_email=admin@example.com

Note: Replace --url with your domain name. Replace --admin_user, --admin_password, and --admin_email value with your value because this will use for admin login. 

Fix ownership:

sudo chown -R nginx:nginx /var/www/newsite

5. Configure PHP-FPM

Edit pool file:

sudo nano /etc/php-fpm.d/www.conf

Set:

user = nginx
group = nginx
listen = /run/php-fpm/www.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Restart:

sudo systemctl enable --now php-fpm
sudo systemctl restart php-fpm

6. Configure Nginx

Create config:

sudo nano /etc/nginx/conf.d/newsite.conf

Paste:

server {
    listen 80;
    server_name example.com www.example.com;

    root /var/www/newsite;
    index index.php index.html;

    access_log /var/log/nginx/newsite.access.log;
    error_log /var/log/nginx/newsite.error.log;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php-fpm/www.sock;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff2)$ {
        expires max;
        log_not_found off;
    }
}

Enable site:

sudo systemctl enable --now nginx
sudo nginx -t
sudo systemctl reload nginx

Allow firewall:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

7. Generate SSL Certificate

sudo certbot --nginx -d example.com -d www.example.com

Choose redirect to HTTPS.

Auto-renew test

sudo certbot renew --dry-run

8. Access domain 

Navigate to your browser and access:

https://example.com

Use full commands:

1. WordPress URLs if needed:

sudo -u www-data wp option update siteurl "https://example.com"
sudo -u www-data wp option update home "https://example.com"

2. Update WordPress Components

Keep your WordPress installation secure and up-to-date easily:

wp core update
wp plugin update --all
wp theme update --all

3. Manage Plugins and Themes

Quickly install and activate plugins or themes:

wp plugin install akismet --activate
wp theme install astra --activate

Deactivate or delete plugins and themes:

wp plugin deactivate akismet
wp plugin delete akismet

4. Database Management

Perform backups and restores effortlessly:

Backup your database:

wp db export wordpress_backup.sql

Restore a database backup:

wp db import wordpress_backup.sql

5. User Management

Efficiently manage users from the command line:

Create a user:

wp user create newuser email@example.com --role=editor --user_pass=password123

Update an existing user’s password:

wp user update newuser --user_pass=newpassword

Automating Routine Tasks

WP-CLI allows you to automate tasks using cron jobs. For instance, to back up your database automatically every day at midnight:

crontab -e

Then add:

0 0 * * * cd /var/www/html && wp db export daily_backup-$(date +\%F).sql

Troubleshooting Common Issues

WP command not found:
Ensure /usr/local/bin is in your PATH variable.

Permission errors:
Make sure WP-CLI is executable (chmod +x) and you're running commands with appropriate permissions.

Database connection errors:
Check your database user, password, and privileges.

Final Thoughts

We have seen how to install WP-CLI is a powerful tool that significantly simplifies WordPress administration. By following this guide, you've installed all required tools and learned essential commands to manage your WordPress sites efficiently directly from your hosting server.

Happy WordPress management!