Apparently, Wordpress is famous for its 5 minute install procedure, and claims upgrading Wordpress is even easiier. And to be fair, it is a reasonably straightforward three (four?) steps:
wp-admin/upgrade.phpURL, which nicely upgrades your DB.
My problem is I'm always, always recalcitrant in upgrading Wordpress, because I cannot help but shirk at Step 1. Have I preserved the correct files (I have a whole lot of custom static content that sits alongside Wordpress)? Did I make any changes anywhere that I need to keep (I once change a core Wordpress file to work around a bug)? How do I even tell if I've accidentally overwritten the wrong file? And at about this stage it gets thrown into the too-hard basket, to be retried next weekend.
But not anymore!
funionfs I no longer have first-step fear. And while some of you may think that fiddling with
yum is a level of complexity well beyond Step 1, I can honestly say that this is what I consider an elegant solution.
A union filesystem is something I've pondered the existence of before (and trust Ivan to know exactly what I wanted). They allow you to fold up a set of separate directory trees and have them appear as one. One of the directories is usually read-write (with copy-on-write), while the others are read-only.
I have a reasonable chunk of static content (images, flash animations, software archives, movie downloads, etc) that I keep in a Subversion repository and deploy to this website via rsync. This content existed before I started using Wordpress, and will exist if I ever stop using Wordpress, so it is not appropriate content for Wordpress to own.
I have Wordpress, which is a whole bunch of
.php and what-not.
I have my all my files that sit on top of Wordpress. My
wp-config.php config file, the
.htaccess file that Wordpress generates so my URLs look cool, some plugins and my theme. It is these files that cause my Step 1 fears. (And in fact, these fears prevent me from making some much needed changes to my theme, too).
All these files, with their different sources and different life-cycles used to be clumped into the one scary directory.
Now, I have three different directories:
/home/matt/madbean.com/static: My rsync-ed static content.
/home/matt/madbean.com/wordpress-2.1-orig: An extracted wordpress-2.1.tar.gz with no modifications.
/home/matt/madbean.com/wp_data: my Wordpress config, plugins, themes, etc.
/home/matt/madbean.com/wordpress_all: An empty directory.
After a bit of fiddling with
funionfs options, I settled on a mount like this:
sudo funionfs -o dirs=\ /home/matt/madbean.com/wordpress-2.1-orig=RO:\ /home/matt/madbean.com/static=RO:\ /home/matt/madbean.com/wp_data=RW:\ NONE /home/matt/madbean.com/wordpress_all
After running that,
wordpress_all contains exactly what Wordpress wants to see: a big mishmash. Any writes Wordpress makes (e.g. to configuration or
.htaccess) get written through to
wp_data. Each time I rsync my static content to
static it is automatically visible in
wordpress_all. And as you will see below, upgrading is a scream.
To ensure this union mount exists next time the box reboots, I converted the above
funionfs instruction into an
funionfs#/home/matt/madbean.com/wp_data /home/matt/madbean.com/wordpress_all fuse rw,nosuid,nodev,allow_other,dirs=/home/matt/madbean.com/wordpress-2.3.1=RO:/home/matt/madbean.com/static=RO 0 0
Having set that up, it was now time to finally upgrade from Wordpress 2.1. This is what it looked like:
$ cd ~/madbean.com $ wget http://wordpress.org/wordpress-2.3.1.tar.gz $ tar fvxz wordpress-2.3.1.tar.gz $ mv wordpress wordpress-2.3.1 $ sudo vi /etc/fstab $ # change the line to refer to wordpress-2.3.1 instead of wordpress-2.1 $ sudo umount /home/matt/madbean.com/wordpress_all $ sudo mount funionfs#/home/matt/madbean.com/wp_data $ sudo /etc/init.d/httpd graceful # for good measure $ # hit upgrade.pgp in my browser
Do you know how happy that made me?
I'm thinking of making the
wp_data directories Subversion workspaces (checked out directories). I can then version control my Wordpress config. And by being able to remotely edit my theme and check it in (and check it out on a test Wordpress server) I'm finally likely to make some changes.