Upgrading WordPress via SSH

WordPress is quite a popular open source CMS that is often praised for its ease of use and simple installation. Like most open source applications, WordPress tends to have upgrades every few months to improve security, stability and the underlying framework.

In recent versions of WordPress, this process has been extremely easy with an automatic upgrade system (something that has also been integrated into the plugin framework too) but on older versions, the process wasn’t particularly straight forward.

Thankfully, I found a rather useful set of commands that you can run on your server via SSH to make this process extremely simple.

Disclaimer: I recommend you always take a backup of the database and working folder before running these commands in case something goes wrong. 99% of the time, I’ve not had any problems with this process but it’s better to be safe than sorry.

# Get the latest WordPress version available.
wget http://wordpress.org/latest.tar.gz

# Uncompress it.
tar xfz latest.tar.gz

# Delete the old wp-includes and wp-admin directories.
rm -rf ./wp-includes/
rm -rf ./wp-admin/

# Go to the new Wordpress directory:
cd wordpress/

# Copy the downloaded files to your existing WP install, overwriting any old files.
cp -rpf -f * ../

# Remove the uncompressed and downloaded files.
cd ..
rm -rf ./wordpress/
rm -f latest.tar.gz

# Visit your blog and upgrade the database (if needed).

Make sure you visit your WordPress installation in the browser straight away to run any upgrade scripts that are required. You should only see one screen and that process is complete.

Written by Si

June 11th, 2009 at 8:55 am

2 Responses to 'Upgrading WordPress via SSH'

Subscribe to comments with RSS or TrackBack to 'Upgrading WordPress via SSH'.

  1. Handy. Very handy.

    Andy

    11 Jun 09 at 11:29 am

  2. Better move the old includes&admin to somewhere else (wpold for example) than removing them straight away - it could all go belly up!

Leave a Reply