Keeping up-to-date wordpress can take some time, especially when you manage multiple blogs. I recently found this amazing tool to manage WordPress through the command line. The tool is WP-CLI, it’s simple to use and so far has saved me lots of time. And above all keeps y blogs updated on the many security updates for Wwordpress and its many plugins.
The general install instructions makes it available system wide. Since I only wanted it available to my user here’s the step I used to get it up and running.
# go to home dir cd ~/ #download wp-cli installer curl http://wp-cli.org/installer.sh > ~/installer.sh # create bin dir if not exists and wp-cli subfolder mkdir -p ~/bin/wp-cli # install in local folder INSTALL_DIR='~/bin/wp-cli' bash ~/installer.sh # symlink wp command ln -s ~/bin/wp-cli/bin/wp ~/bin/wp # test that it works ~/bin/wp --info
Now that it’s installed make sure that ~/bin is in your $PATH to run the command anywhere. Make sure you have the following lines in your ~/.profile
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi
Enable wp-cli autocomplete by adding the following line to your ~/.bashrc or ~/.bash_profile.
source $HOME/bin/wp-cli/vendor/wp-cli/wp-cli/utils/wp-completion.bash
Now make sure both files are loaded in your current sesssion.
source ~/.profile source ~/.bashrc
Before you being make sure you have a back up of your database and files.
Now you are ready to start managing WordPress through the CLI. Here are a few example of useful commands:
# First change to the top directory of your blog # cd /var/www/... # check the current version wp core version # to update to the latest version wp core update wp core update-db # to see if plugins need to be updated wp plugin list # To update akismet plugin wp plugin update akismet # To find a plugin with the word secure wp plugin search secure # To install the plugin with the slug secure-wordpress wp plugin install secure-wordpress