AdminsForum

CloudPanel WordPress Guides

Guide WP-CLI on CloudPanel: Manage WordPress from the Command Line

Started by JAY 0 replies 111 views
1JAY
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
#1
WP-CLI on CloudPanel: manage WordPress from the command line

WP-CLI lets you do WordPress jobs by typing short commands instead of clicking through wp-admin. Updating every plugin, resetting a forgotten admin password or changing your domain in the whole database takes one line. It's also a lifesaver when wp-admin itself is broken and you can't log in.

This guide shows the commands you'll actually use, explained in plain words.

Before you start: log in as the site user
Always run WP-CLI as the site's own user, never as root. That way new files get the right owner and you don't create permission problems.
Code:
ssh site-user@YOUR_SERVER_IP cd ~/htdocs/www.example.com
Every command below is run from this folder (the one that contains wp-config.php).

Check that WP-CLI is available:
Code:
wp --info
If you see "command not found", ask the server admin to install it as root:
Code:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar mv wp-cli.phar /usr/local/bin/wp

See what's going on
Code:
wp core version # which WordPress version you run wp plugin list # all plugins, active or not, and if updates are waiting wp theme list # all themes wp user list # all users and their roles

Update everything safely
Take a quick database backup first, then update:
Code:
wp db export ~/backup-before-update.sql wp core update wp plugin update --all wp theme update --all wp core update-db
If something breaks after an update, you can roll a single plugin back to a version you know works:
Code:
wp plugin install woocommerce --version=9.0.0 --force

Fix a site that won't load
A broken plugin is the most common cause of a white screen. Turn off all plugins at once, check the site, then turn them on one by one:
Code:
wp plugin deactivate --all wp plugin activate contact-form-7
Switch to a default theme if the theme is the problem:
Code:
wp theme activate twentytwentyfive

Reset a forgotten admin password
Code:
wp user update admin --user_pass='a-new-long-password'
Replace
Code:
admin
with your username (see
Code:
wp user list
). Or create a fresh admin user:
Code:
wp user create newadmin [email protected] --role=administrator
WP-CLI prints the new password on screen.

Change the domain (or move from HTTP to HTTPS)
WordPress stores your address in many places in the database. This command replaces it everywhere safely. Always test with
Code:
--dry-run
first, which only shows what would change:
Code:
wp search-replace 'http://old-domain.com' 'https://www.new-domain.com' --dry-run wp search-replace 'http://old-domain.com' 'https://www.new-domain.com'
Then clear your caches (next section).

Clear caches
Code:
wp cache flush # WordPress object cache wp transient delete --all # old temporary data wp rewrite flush # refresh permalinks
If you use Varnish in CloudPanel, also purge it from the site's Varnish Cache tab.

Back up and restore the database
Code:
wp db export ~/site-$(date +%F).sql # backup with today's date wp db import ~/site-2026-10-19.sql # restore a backup
Keep backups outside the htdocs folder (like the home folder above), so nobody can download them from the web.

Run WordPress cron reliably
WordPress normally runs its scheduled jobs only when someone visits the site. On quiet sites, scheduled posts and emails can be late. You can run them on a timer instead:
  1. Add this line to wp-config.php, above "That's all, stop editing":
    Code:
    define( 'DISABLE_WP_CRON', true );
  2. In CloudPanel, open the site's Cron Jobs tab and add a job that runs every 5 minutes with this command:
    Code:
    cd /home/site-user/htdocs/www.example.com && /usr/local/bin/wp cron event run --due-now >/dev/null 2>&1
Cron jobs don't always know where WP-CLI lives, so use its full path. Run
Code:
which wp
to check it; on most servers it's
Code:
/usr/local/bin/wp
.

Quick reference
  • Code:
    wp plugin list
    : see all plugins
  • Code:
    wp plugin update --all
    : update all plugins
  • Code:
    wp plugin deactivate --all
    : emergency switch-off
  • Code:
    wp user update NAME --user_pass='...'
    : reset a password
  • Code:
    wp search-replace OLD NEW --dry-run
    : preview a domain change
  • Code:
    wp db export file.sql
    : database backup
  • Code:
    wp cache flush
    : clear the object cache

Sources (checked October 2026): WP-CLI official site · WP-CLI command reference

Related: Install WordPress in CloudPanel
Reply

Messages In This Thread
WP-CLI on CloudPanel: Manage WordPress from the Command Line - by JAY - 10-19-2026, 02:41 PM
Possibly Related Threads…matched by title
Replies:0Views:98
Replies:0Views:160

Users browsing this thread: 1 Guest(s)
Forum Jump: