rss_feed

Update Multiple WordPress Installations

15 February 2016

Between several of my own websites as well as the websites I’ve done for other people and am hosting, the number of WordPress installations on my server has climbed exponentially. There are people that will say that’s a terrible thing and there are others that will argue it’s perfectly fine. Either way, it’s a fact I have to deal with at the moment.

In order to make my life a bit easier, however, I’ve come up with a way to automatically keep all of my installations up-to-date which is, of course, extremely important for security. This trick will work if you have a *nix-based server and SSH access.

First, we need to install WP-CLI which is a PHP-based command line interface for WordPress. It is very easy to install and the instructions are right on the homepage.

Secondly, we need a bash script. Since WP-CLI has commands to update the WordPress core, all plugins and all themes, we will take advantage of these in our script to update everything at once. The bash script looks like this:

#!/bin/bash

function updateWordPress {
  cd $1
  wp core update
  wait
  wp plugin update --all
  wait
  wp theme update --all
  wait
  wp core language update
  wait
  printf "\n\n"
}

If you replace “blog name” and /path/to/blog with the appropriate values, it will then update that blog. In order to update multiple WordPress installations, you just copy the last two lines for each blog replacing “blog name” and /path/to/blog as necessary for each installation.

This code is also available as a GitHub Gist.

How would you rate this post?

About the Author

Alex Seifert
Alex is a developer, a drummer and an amateur historian. He enjoys being on the stage in front of a large crowd, but also sitting in a room alone, programming something or writing about history.

Related Posts

Post a Comment

Your email is kept private. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>