We will introduce to you a useful command-line tool, "WP-CLI".
WP-CLI is a command line tool that can do almost everything about WordPress.
- Installation or upgrade of WordPress core
- Install updates for plugins and themes, enable and disable
- Managing Databases
- Operating posts and pages
WP-CLI is installed in AMIMOTO AMI ver1.1 or later.
Operation example using WP-CLI
First of all, please cd to the directory where WordPress is installed, then run the wp command.
If you use Amimoto AMI and logged in as ec2-user, you can't create directories and files, run it with
Check the info of the installed plugins with:
$ wp plugin status
Enable and disable plugin(s) (can be specified more than one)
Enable and disable Akismet and WP Multibyte Patch.
$ wp plugin activate wp-multibyte-patch akismet $ wp plugin deactivate wp-multibyte-patch akismet
Install and enable (example: Breadcrumb NavXT)
$ wp plugin install breadcrumb-navxt --activate
※ It is also possible to install by specifying the .zip file of a plugin other than the official directory.
$ wp plugin update UPDATE-PLUGIN
$ wp plugin update akismet
Import and export of database
$ wp db export foo.sql $ wp db import foo.sql
※phpMyAdmin is available in Amimoto managed hosting plan.
Using phpMyAdmin is possible by rewriting the conf file if you have created an instance from Amimoto AMI by yourself.
Search and replace text in the database
$ wp search-replace --skip-columns=gui REPLACE-ME REPLACED-ME
$ wp search-replace --skip-columns=gui http://example.dev https://example.com
※string that has been serialised are also processed correctly.
The command line
You can perform almost all the same actions from the dashboard as commands introduced here. The advantage of doing with commands is that you can automate those actions. For example, if you want to install some plugins you always use, you may search, install and activate those plugins from the dashboard for each time, however, with using WP-CLI, once you write a shell script to do those actions, you just run the script for the new installation of WordPress.
We introduced some examples. WP-CLI has a lot of commands; please refer to the official documentation:
Built-in Commands | WP-CLI http://wp-cli.org/commands/