This post is inspired by Alex King's WordPress updates via Subversion.
Currently I have got 7 installations of WordPress running various sites of mine (excluding around 20 other installations at FOCUSer.net which I also manage). Each site runs more or less a similar set of plugins (some of them developed by myself), but each installation has its distinct theme. Unlike Alex, I do not edit WP's source code so Subversion's merge-on-update has little use to me. However, with Subversion's
svn:externals property, it is now trivial to keep your WordPress installations and many plugins and even themes up to date, with a single
svn update command.
Install WordPress via Subversion
There are some instruction on WordPress' download page on how to install WordPress via Subversion. However, the instruction is targeting developers and source that gets checked out is the trunk, i.e. the branch that has been actively developed upon and will hopefully become 2.1 in the near future. It is not suitable for a production site, which the current stable branch 2.0 is much preferred.
To check out the 2.0 branch, use the following command instead:
svn checkout http://svn.automattic.com/wordpress/branches/2.0/
A directory "2.0" will be created containing the complete WordPress 2.0 source code. Move/rename it to whatever you want, and you can pretty much start WP's "5 minute install" from this freshly checked out tree.
Install Plugins via Subversion
You can only install plugins that have Subversion repository. Everything hosted on WP Plugin Repository has one. Plugins that I wrote also have Subversion repository hosted at DreamHost (mental note to myself: need to remember to publish those repositories).
The key is to edit the "
svn:externals" property on the
wp-content/plugins directory to include those plugins. They will be installed into their own directory, but that's fine -- WordPress can grab plugins from sub-directories.
For example I wish to install both Permalink Redirect and Mark Jaquith's Subscribe to Comments plugins. First of all, change directory to
wp-content/plugins, and issue the following Subversion command:
svn propedit svn:externals .
It will bring up your favourite text editor (note: it can't actually guess so be sure your
EDITOR environment variable has been set) to edit the
svn:externals property on that directory. For a stock WP 2.0 installation, you'll see Akismet plugin is already there. Now, add the entries for the two plugins that you wish to install there.
It is in the format of "<directory name> <repository URI>". Now save the file and quit the browser. Nothing happened -- until you try to update the directory. By issuing the command:
Subversion will pull both plugins from two different repositories and put them under your installation. Now go to your WordPress admin page, and you should be able to see the two new plugins there. Neat huh?!
To upgrade your WordPress installation that has been previously checked out to the latest revision in the same branch (for example, 2.0.3 when it gets released), you just need to go into your WP directory and issue this command:
It will then automatically pull all the updates from remote repository and apply to your installation, doing 3-way merges with files you have changed if necessary. Resolve any conflicts if you have spot any.
Since Subversion updates propagate through directories, it will also try to pull any update to the plugins that you have installed. In fact you can run
svn update as often as you like to ensure all your svn-installed plugins are on their latest version.
To upgrade to a new version of WordPress that is on a different branch, you will need to use the
svn switch command. For example, WP 2.1 has just been released and you want to be the first to run it...
svn switch http://svn.automattic.com/wordpress/branches/2.1/
You then have to follow WordPress instructions on updating the database, resolving incompatibility with themes and plugins, etc.
Installing WordPress via Subversion has saved me many troubles trying to synchronised various code pieces between sites -- now they all live inside repositories and each installations are merely checkouts of those repositories. For shared code pieces I used for all sites, I just wrap the code inside a mega-plugin, put that into my own SVN repository, and then use
svn:externals to include it into each of my sites.
In fact, I also put all my customised themes into SVN repository and add them back in the
wp-content/themes directory using the same method. I think the WordPress theme repository should deploy Subversion as well, so that theme users can get quick updates whenever the theme author has committed the latest change.
Update: As per Matt's suggestion, there is actually a WordPress themes repository which you can use
svn:externals to import themes. Nice.