WordPress plugin installation using wp-cli
Before diving into details I would like to clarify that using wp-cli for extension installation is method for more advanced users because it requires at least basic SSH skills and of course SSH service enabled on the server. Apart of this wp-cli needs also to be enabled on the server, so if you are not sure whether wp-cli exists, just get in touch with your support team and ask for assistance.
In my case I have wp-cli installed and enabled on the server level, so I am ready to start working with it. My first steps is login to the account using SSH and navigate to wp-content/plugins folder of my WordPress instance. Then upon typing ls –la command, which will list the content of that folder I see the existing plugins. Currently I have the following ones:
Jetpack and Akismet
Following the course of this tutorial I will install WP Super Cache using wp-cli. To do so I just type this command:
wp plugin install wp-super-cache
which will generate the following output:
Installing WP Super Cache (1.4.7)
Downloading install package from https://downloads.wordpress.org/plugin/wp-super-cache.1.4.7.zip…
Unpacking the package…
Installing the plugin…
Plugin installed successfully.
Success: Translations updates are not needed for the ‘English (US)’ locale.
Then upon typing ls –la command I see WP Super Cache in the list. At this point the plugin is installed, but not activated. To turn it on I need to execute this command wp plugin activate wp-super-cache. Its output is placed below:
# wp plugin activate wp-super-cache
Success: Plugin ‘wp-super-cache’ activated.
Now the plugin is installed and activated. To configure it to my needs I need to go wp-admin section -> Settings -> WP Super Cache and apply the necessary changes.
Of course wp-cli comes with great manual page. If you are not sure that the correct command for plugin installation is, just type wp plugin and you will see the following output:
usage: wp plugin activate [<plugin>…] [–all] [–network]
or: wp plugin deactivate [<plugin>…] [–uninstall] [–all] [–network]
or: wp plugin delete <plugin>…
or: wp plugin get <plugin> [–field=<field>] [–fields=<fields>] [–format=<format>]
or: wp plugin install <plugin|zip|url>… [–version=<version>] [–force] [–activate] [–activate-network]
or: wp plugin is-installed <plugin>
or: wp plugin list [–<field>=<value>] [–field=<field>] [–fields=<fields>] [–format=<format>]
or: wp plugin path [<plugin>] [–dir]
or: wp plugin search <search> [–per-page=<per-page>] [–field=<field>] [–fields=<fields>] [–format=<format>]
or: wp plugin status [<plugin>]
or: wp plugin toggle <plugin>… [–network]
or: wp plugin uninstall <plugin>… [–deactivate] [–skip-delete]
or: wp plugin update [<plugin>…] [–all] [–format=<format>] [–version=<version>] [–dry-run]
See ‘wp help plugin <command>’ for more information on a specific command.
The same applies for the rest of the command, for example wp theme.