If you know how to log in via SSH (Secure Shell Access), then you will be able to upgrade your WordPress site in three minutes or less by using the following lines of code.
I have to admit right away that I’m highly indebted to this pre-existing tutorial from Techtites. But that tutorial is a little dated for the newer versions of Linux, and one of the commands given there no longer works on my web server, because it’s been deprecated (I use 1and1). I thought it useful to provide the right commands in this post, and to keep it updated in case something changes.
A few words of CAUTION:
- BACK UP all of your site files and your site database before running the upgrade. Take the time to do both, or you may deeply regret it later. As a matter of fact, it’s a great idea to back up your site files and database on a weekly basis, if not more often, just in case you get hacked or the web server crashes, etc.
- I’m not a Linux expert. I’m just glad I found these commands and that they’ve made the upgrade process easier for me. Don’t ask me to help you configure this for your web server. If the commands don’t work there, or something gets screwed up, you’re on your own.
- Should you use the WP-Cache plugin, disable it and delete any cached files BEFORE running the upgrade process. Even better, disable ALL your plugins before the upgrade process. If you don’t do this, you may get a big, fat 500 error afterwards.
Now, initiate a SSH session to your web server (I use Putty). Your web host should have the directions on how to do this. Go to the root level of your site/WP install folder (this is NOT the same as the root level of your SSH login).
Once you’re at the root level of your WordPress install (the one where you can see the wp-config.php file), enter the following Bash commands, in the order they appear. Wait for each of them to execute successfully before proceeding to the next one.
This will download the latest version of WP directly from WordPress.org:
This will unzip it, creating a directory called wordpress:
tar xfz latest.tar.gz
This will delete the wp-includes and wp-admin folders:
rm -rf ./wp-includes/
rm -rf ./wp-admin/
This will take you inside the wordpress folder:
This will copy everything inside the wordpress folder to the root level of your site, overwriting any existing files and directories. This line is the only line that’s changed from the Techtites tutorial:
cp -rpf -f * ../
This will take you back out to the root of your WordPress install:
This will delete the wordpress directory and the downloaded WP archive, since they’re not needed any more:
rm -rf ./wordpress/
rm -f latest.tar.gz
Hope this helps!
4 thoughts on “How to install or upgrade WordPress via SSH”
Please be aware that some upgrades require the new files from the root directory too. Just tried to do this on an old install and had an some errors.
Pingback: Simon Young | Freelance Web Designer, Web Developer in Manchester, Chester
Thankz for the informations.
This is a great tutorial and has saved me a lot of time. I would add though to the wget command, ‘–output-document latest.tar.gz’. Example:
wget –output-document latest.tar.gz http://wordpress.org/latest.tar.gz
This will allow you to use the command: ‘tar xfz latest.tar.gz’ otherwise the WordPress version is in the file name. Thanks again!
Comments are closed.