Short note four
Fri, Feb 15, 2019 · 2 minute readlinuxwordpress
Install WP-CLI
Download wp-cli, install curl if not already installed:
$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
-bash: curl: command not found
$ sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
curl
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 163 kB of archives.
After this operation, 404 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu cosmic-updates/main amd64 curl amd64 7.61.0-1ubuntu2.3 [163 kB]
Fetched 163 kB in 0s (6,357 kB/s)
Selecting previously unselected package curl.
(Reading database ... 21354 files and directories currently installed.)
Preparing to unpack .../curl_7.61.0-1ubuntu2.3_amd64.deb ...
Unpacking curl (7.61.0-1ubuntu2.3) ...
Setting up curl (7.61.0-1ubuntu2.3) ...
$ 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 5294k 100 5294k 0 0 20.4M 0 --:--:-- --:--:-- --:--:-- 20.4M
Test wp-cli by displaying system information:
$ php wp-cli.phar --info
OS: Linux 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.2
PHP version: 7.2.15-0ubuntu0.18.10.1
php.ini used: /etc/php/7.2/cli/php.ini
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: /home/bits02-c09
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.1.0
Configure wp-cli and move to system directory:
$ chmod +x wp-cli.phar
$ sudo mv wp-cli.phar /usr/local/bin/wp
Retest installed ‘wp’, displays same information as before - we’re good:
$ wp --info
OS: Linux 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 09:04:24 UTC 2018 x86_64
Shell: /bin/bash
PHP binary: /usr/bin/php7.2
PHP version: 7.2.15-0ubuntu0.18.10.1
php.ini used: /etc/php/7.2/cli/php.ini
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: /home/bits02-c09
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.1.0
bits02-c09@bits02-c09:~$
Things you can do with wp-cli
Update site options
e.g. change the site and home URL’s from https to http and back.
$ wp option update home 'http://new.co.uk'
Success: Updated 'home' option.
$ wp option update siteurl 'http://new.co.uk'
Success: Updated 'siteurl' option.