How to Upgrade WordPress via SSH
For most WordPress users updating to a newer version is pretty straight forward: log into the WordPress dashboard, click on “Updates” and then select the option to update WordPress. Within 10 seconds or so you are set.
Depending on the settings of your server, though, the automatic update option will not work. In this case you’ll need to perform the update manually, which means deleting and uploading the files via FTP, which takes a lot of time (around 15 minutes for all WordPress files with an average Internet connection).
Is there a better way? Yep, and it’s called SSH. SSH stands for Secure Shell, and it’s a protocol for remote communications. Using this protocol you can basically connect to your server and perform commands as if you were using the computer personally.
Warning: Make sure to backup all your data and databases before trying any type of update, as you could mess things up and lose everything. Try the stuff below at your own risk.
First of all you need to contact your hosting provider to make sure you have SSH enabled on your account. After that you can login to your server by typing
on the command line, and after that you’ll be prompted to put your password. Usually the user and password are the same of your FTP account, but they might be different.
Once you are logged in you need to browse to your public_html directory, which is usually where WordPress is installed. If you are using a sub-directory, navigate to it. Then type this to download the latest WordPress files:
After that type this to decompress the file:
tar xfz latest.tar.gz
Next we need to delete the wp-admin and wp-includes directories, which you can do with the following commands:
rm -rf ./wp-includes
rm -rf ./wp-admin
Now you want to move the new wp-admin and wp-include directories to the root, so type the following commands:
mv ./wordpress/wp-admin ./
mv ./wordpress/wp-includes ./
Finally, go inside the WordPress directory with
and copy its content to the parent directory (i.e., the root) overwriting the old ones:
cp -rpf -f * ../
Finally, type “cd ..” to go back to the root directory and delete both the tar file you downloaded and the wordpress directory with this:
rm -rf ./wordpress/
rm -f latest.tar.gz
That’s it. All you have to do now is to run the upgrade script on your WordPress install (i.e., domain.com/wp-admin/upgraded.php).
Get My Best Internet Marketing and Entrepreneurship Tips
- Don't worry, I only send out emails once or twice a month.
- But when I do, it's because I have something valuable to share!
- You don't want to miss those, and it's completely free!
8 Responses to “How to Upgrade WordPress via SSH”
Rashmi Sinha @ TechInitio
SSH is a great protocol to do things from a remote location. As we all know, updating wordpress is very important and we have to do it a.s.a.p. Really nice guide and tips to update it immediately.
Have we considered the security implication?
@Okoji, which one?
Very helpful site. I don’t know if I am ready to transfer to WordPress yet, though.
excellent post Daniel – I am having problem with my current host besides it seems quite cool & geeky to use console to upgrade WordPress 🙂 – I will practice it on test domains and will impress few friends 😉
Chris @ NPI
There is a great plugin for making backups – BackUpWordPress.
It’s free, and you make backup of all files and database.
Cool! Neat way of updating my site. I’ll try this one and see how it works.
Thanks for the tutorial Daniel, I really liked it.
Comments are closed.