Upgrading Wordpress can be a major pain (if you don’t know what you’re doing). For example, lets say that you know nothing about the UNIX command line.
The typical update path would either use the built in wordpress upgrade function (which doesn’t work for all server setups) or something like:
- Visit wordpress.org
- Download the latest zip file to your pc
- Unzip the latest file
- Fire up your FTP program
- Connect to your server
- Navigate to your blog folder
- Upload the new Wordpress files
- Wait 5+ Minutes for the files to upload one by one
- Visit the upgrade page on your Wordpress Blog
- Finished!
Doing the above could take 15-20mins or more. So how can we do it in less than 10 seconds? Easy, via the command line.
How to Upgrade Wordpress from the Linux/UNIX command line
Log into your shell account & replace /var/www/ with the folder that your blog resides in (i.e. home/blog/public_html).
tar -zcvf /var/www/wordpressbackup/120809.tar.gz /var/www/blog mkdir /var/www/tmp cd /var/www/tmp wget http://wordpress.org/latest.zip unzip latest.zip cd /var/www/blog cp -avr /var/www/tmp/wordpress/* . rm -rf /var/www/tmp/wordpress /var/www/tmp/latest.zip
So, looks simple eh? Lets have a look at what these commands do:
- Takes a backup of your current Wordpress installation (change the date to the current date)
- Makes a new directory called tmp
- Changes to the tmp directory
- Grabs the latest wordpress zip file
- Unzips the wordpress zip to the tmp directory
- Changes to the blog directory
- Copies & replaces everything in your wordpress directory with the new files
- Removes the tmp directory & the zip file
Caveats
There are a few issues with this method that you should be aware of before trying yourself.
- The folder that your blog sits in will be different then /var/www/blog/ so make sure you change this.
- The commands overwrite existing files but it do not delete legacy or discontinued files
- Make sure you backup your directory & mysql database just incase your make any mistakes
Done upgrading? Now you can check our other guide on speeding up & optimizing Wordpress.
