How Can We Help?

How To Install WordPress WP-CLI (command line interface)

You are here:
< All Topics

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6342k 100 6342k 0 0 2773k 0 0:00:02 0:00:02 –:–:– 2773k

 

root@asus:~# php wp-cli.phar –info
OS: Linux 5.8.0-63-generic #71-Ubuntu SMP Tue Jul 13 15:59:12 UTC 2021 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.4
PHP version: 7.4.9
php.ini used: /etc/php/7.4/cli/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.3.29-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
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: /root
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.6.0
root@asus:~#

 

root@asus:~# chmod +x wp-cli.phar
root@asus:~# sudo mv wp-cli.phar /usr/local/bin/wp
root@asus:~#

 

wp cli version

 

root@asus:~# wp cli version
Error: YIKES! It looks like you’re running this as root. You probably meant to run this as the user that your WordPress installation exists under.

 

If you REALLY mean to run this as root, we won’t stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.

 

If you’d like to continue as root, please run this again, adding this flag: –allow-root

 

If you’d like to run it as the user that this site is under, you can run the following to become the respective user:

 

sudo -u USER -i — wp <command>

 

root@asus:~#

 

 

usage examples:

root@asus:~# wp plugin list –path=/var/www/wordpress –allow-root
+——————————————-+———-+———–+————–+
| name | status | update | version |
+——————————————-+———-+———–+————–+

… plug list follows….

 

 

root@asus:/usr/local/bin# wp core version –path=/var/www/wordpress –allow-root
5.9.3
root@asus:/usr/local/bin#

 

wp cache flush –path=/var/www/wordpress –allow-root

 

 

root@asus:~# wp cache flush –path=/var/www/wordpress –allow-root
Success: The cache was flushed.
root@asus:~#

 

 

Table of Contents