This text and video Quick Guide covers how to install WP-CLI, the WordPress command line interface.
What WP-CLI Is and Why to Install WP-CLI
First off, WP-CLI is a command line utility. We’ve written a number of articles about how to do various things on the Unix command line. The highlight articles are:
- What is the Command Line? CLIs from First Principles
- 10-ish Unix CLI File Commands Every WordPress Developer Should Know
- Mastering the Unix Terminal: Working With Permissions, Networking, and Other Key Concepts
For a WordPress developer, a lot of this is nice to know but not super-useful—without a system that lets us do WordPress development in the command line. WP-CLI is exactly that system.
WP-CLI is a Unix command line package that really makes it worth figuring out the command line. It makes doing lots of little administration tasks on you WordPress server so much easier.
We’ve made an entire free course on using WP-CLI:
https://wpshout.com/course-working-command-line-wp-cli/
But the first thing you’ll need to understand is how to install WP-CLI itself. The video and the text below will show you how.
Here’s the video:
And here’s a text guide to installing WP-CLI:
How to Install WP-CLI (and What Each Step Does)
- Open a command prompt. Probably BASH.
- Paste in the command:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
and hit enter. This will download the file from the URL onto your computer and into your current directory. - Make sure the above command worked via a run of `php wp-cli.phar –info`. If you get output, keep going. If not, redo step 2. (We’re just running WP-CLI here, with one of it’s simplest commands.)
- Make the
phar
executable via `chmod +x wp-cli.phar`. CHMOD is the method to change permissions on a file, we need it be executable so that we can invoke it without calling PHP first (as we did in step 3). - Rename and move the executable into your path (see the end of my Unix concepts article for details), so that you can type
wp
to run the command.sudo mv wp-cli.phar /usr/local/bin/wp.
- Confirm everything worked by running
wp --info
.
And that’s it! Now that you’ve got WP-CLI installed, have a look at our free course on WP-CLI. Happy hacking!
[…] Installing WP-CLI […]
[…] Quick Guide: Installing WP-CLI […]
[…] into your terminal is doing. If you’re looking for that check out our latest Quick Guide: Installing WP-CLI. Here’s its […]
[…] Installing WP-CLI […]