I’ve been running WordPress 3.0.5 for a while now, as it’s the version in the current Debian ‘stable’ repository. For a while now I’ve been meaning to move to the latest and greatest (which, as I write, is 3.3.1), but didn’t want to mess about with pinning in apt to run a ‘mixed system‘. WordPress has had its own automatic upgrade system since 2.7, and with a history of nasty vulnerabilities, I want to be able to apply upgrades as soon as they are released by the WordPress team.
The procedure I followed is broadly similar to WordPress’s own manual update procedure. I’m assuming that you have shell access to your server, and that your WordPress installation is pretty standard for a Debian system.
- Backup your database (something like
mysqldump --all-databases -p > mysql.dump
- Download the latest WordPress release, and unpack it in /opt (to keep it away from anything managed by the Debian packaging system.
- Deactivate all plugins from the dashboard in case there are any incompatibilities.
cp -pr /usr/share/wordpress/wp-content /tmp
cp -pr /opt/wordpress/wp-content/* /tmp/wp-content
rm -r /opt/wordpress/wp-content
mv /tmp/wp-content /opt/wordpress
ln -s /etc/wordpress/wp-config.php /opt/wordpress
- Copy anything you’ve added yourself from /usr/share/wordpress to /opt/wordpress…
- …and ditto for /usr/share/wordpress/wp-admin (to /opt/wordpress/wp-admin).
The last two steps are very important. I have .htaccess files in both directories (the latter for security—highly recommended, by the way), and other bits and pieces as well. Don’t copy any stock WordPress files, only those that you’ve added yourself and want to keep.
At this point, your new WordPress installation is configured and ready to go, but not yet in use. The final step is to change the symbolic link in /var/www to point to the new installation, and it’ll start being used immediately. For me this was a case of
mv rainbow.chard.org old
ln -s /opt/wordpress rainbow.chard.org
Give it a quick test, and if all is well you’re nearly finished. If it’s broken, just
rm rainbow.chard.org; mv old rainbow.chard.org (remember to use your domain and not mine :-)). If you’ve got this far and have a shiny new WordPress installation, log into the dashboard—you might be prompted to upgrade the database—and re-enable your plugins. That’s it!
Remember that, although you still have the Debian WordPress packages installed, they’re not being used any more. At some point you could remove them, although I keep them around just in case something terrible happens.