(To skip all the drama and go directly to getting a WordPress site with WP CLI running in just a few steps, click here.)
I’ve been working with WordPress for quite a while now, both hobby and professional, and I’ve always held off using WP CLI, the command-line interface for doing things. Because all that can be done in our admin tool anyways, so why bother, right?
But, I did try a few times. And failed every single time. Why? Mostly because I’m a Windows user, and most of the guides, tutorials, tools, and everything else in tech world assumes you’re on a Mac (I tried that too for a year or so, and was very happy to go back to Windows).
WP CLI‘s page states as the first requirement: “UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment“. Well that’s just great.
Maybe install VVV, that will create a virtual machine with that important UNIX-like environment? That’s probably where my stupidity came in, cause I couldn’t get that to work properly either. I think. Maybe I did. Maybe it was just a bit too much for what I needed. Either way, I wasn’t happy for some reason, so I yelled “EVERYONE HATES DEVELOPERS WHO ARE ON WINDOWS!“, cried over some tacos, and dropped it again.
So recently, I decided to give it another go. This may or may not have to do with the fact that I’m using WP CLI at work now, so I thought it wouldn’t be a bad idea to have a local copy available where I could experiment a bit with it. After finding a simple (but good) Vagrant box and tweaking it a bit, I think I ended up with pretty simple way of having a basic WordPress site running in an environment that totally supports WP CLI, on Windows. Bonus: it should work just as well on a Mac.
Enough! How to get this running?!
All done? Let’s go.
Ummmm….that’s pretty much it. You should now have a WordPress site running at http://wp-cli.local.
You can now SSH into the server (using putty.exe on Windows, or Terminal on Mac) by connecting to wp-cli.local (username/password:
Once in the server, type
cd /var/www/html/wordpress and you can WP CLI all you want. I won’t get into all that here, but you can find all the handy commands and documentation at https://developer.wordpress.org/cli/commands/.
- Username and password for http://wp-cli.local is wp/wp.
- This whole method is not super secure, since I’ve hard-coded some passwords. You can change that (before you run step 3 above) in
/mywebsite/vagrant/shellprovider.sh, lines 121, 133 and 134.
- Access phpMyAdmin with username
rootand no password.
- To stop the virtual machine, enter