Hello everyone, today I am going to share with you a shell script I have been using to easily update my WordPress blog installation (and can easily be expanded to upgrade multiple blogs as well). The script I wrote automatically downloads the latest version of WordPress, extracts it, and updates your blog files. In order to run this script you will need SSH access and the ability to run shell scripts. This script was written to work with my host which runs on cPanel, but it can easily be altered to work on other systems as well by modify the directories. Below are instructions on how you can go about using this shell script to easily upgrade your blog.
- Login to SSH with your cPanel username and password
- Create a directory called upgrade_blog/ in your home directory (mkdir ~/upgrade_blog)
- Navigate to the upgrade_blog directory (cd ~/upgrade_blog)
- Create a new file called “run.sh” using your text editor of choice (I use nano)
- Paste the following code into the run.sh file:
rm -rdf ~/upgrade_blog/latest.zip ~/upgrade_blog/wordpress/ wget http://wordpress.org/latest.zip unzip latest.zip cp -r ~/upgrade_blog/wordpress/* ~/public_html/blog/
- Save the file
- To update your blog just simply navigate to the upgrade_blog/ directory in SSH and execute the run.sh file (sh run.sh)
- The script automatically downloads the latest version of WordPress and updates your blog accordingly.
- Once the script has finished executing open up your blog and go to your admin. WordPress will ask you to upgrade your database if it is needed.
- If you want to upgrade multiple blogs just copy the last line from the script and change the directory it copies the WordPress files to.
- Note: This script is based off of of the assumption that your blog is located in public_html/blog if your blog is located elsewhere change it.
And that’s all there is to it. Enjoy.
