WordPress Keeps Updating Like Hell
If you use wordpress (like me) to power up your blogging engine, you would know that wordpress keeps on releasing new versions. Year 2012 saw 15times releases! That can get irritating at times, but you have no choice than to keep your software/systems up-to-date. You can see all the releases here.
I will show you how I do this quick and fast – it takes me at most 30mins. I’m am hosted on Linode VPS and I use the bash shell/terminal to do all these manually.
A Quick Linode Thankful-ness – I Am A Happy Linode Client
I am a happy Linode.com user back since mid 2011, awesome support, great uptime and a passionate community behind to drift (like tokyo-drift awesomeness) their technology forward and keep being innovative. I just LOVE the Linode community, they simply rock! Below you will find a screenshot of the longest day my server for 7php.com was ON without any issue.
I had to reboot because Linode has now deployed more nice-ness to us, their clients; namely 8-cores, more RAM and more bandwith(you can see for yourself on their home page).
How To Manually Update WordPress On VPS
Assumptions:
- You know a little bit how to use Terminal aka bash shell – I will guide you though
- You have already change directory to your current root folder
- The root folder in this example is named as WWW
- The folder where your wordpress stuffs resides is called public and resides beneath/inside WWW
- This guide, the way I do it, I use only Terminal, but this is not by any means the only way, you could do that by using an sFTP (like FileZilla) program as well.
STEP 1 – do a backup of your ‘public’ folder
Let assume your root folder is WWW and has the following tree:
WWW
└── public
Now do a backup/copy using the following command:
[lang=’bash’]
$ cp -r public public_bak
[/lang]
This command simply makes a (recursive) copy of the folder public and names it as public_bak.
So now your new WWW folder is as follows:
WWW
├── public
└── public_bak
STEP 2 – get the latest WordPress source
1- Download the latest wordpress source to your root WWW folder using the following command:
[lang=’bash’]
$ wget http://wordpress.org/latest.zip
[/lang]
Updated Tree structure is now:
WWW
├── public
├── latest.zip
└── public_bak
2- Unzip the download zip file using the following command:
[lang=’bash’]
$ unzip latest.zip
[/lang]
NOTE:
- If you do not have zip installed, do $ apt-get install zip
- The extracted folder is by default named as wordpress
Updated Tree structure is:
WWW
├── public
├── latest.zip
├── wordpress
└── public_bak
At this stage, I like to delete things I do not use, so I will delete latest.zip:
[lang=’bash’]
$ rm latest.zip
[/lang]
Updated Tree structure is:
WWW
├── public
├── wordpress
└── public_bak
STEP 3 – Put your current wordpress blog into maintenance mode
1- Create a file named as .maintenance in your public folder
– Change directory to public
[lang=’bash’]
$ cd public
[/lang]
The tree structure of public is as follows:
public
├── wp-admin
├── wp-content
├── wp-includes
├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-cron.php
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php
[lang=’bash’]
$ nano .maintenance
[/lang]
This command will create a file .maintenance and opens it using the inbuilt editor called “nano“.
Paste the following php code inside it.
2- add the following code inside it
[lang=’php’]
$value ) {
if ( stristr($cookie, ‘wordpress_logged_in_’) )
$loggedin = true;
}
return $loggedin;
}
if ( ! stristr($_SERVER[‘REQUEST_URI’], ‘/wp-admin’) && ! stristr($_SERVER[‘REQUEST_URI’], ‘/wp-login.php’) && ! is_user_logged_in() )
$upgrading = time();
?>
[/lang]
After that, we need to tell “nano” to save it and exit itself and go back to the terminal. We do this by clicking the following Keyboard buttons:
– CTRL + o
– CTRL + x
The udpated Tree is now:
wordpress
├── .maintenance
├── wp-admin
├── wp-content
├── wp-includes
├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-cron.php
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php
NOTE:
- To list all the directories you do $ ls
- But for files starting with a dot (.), these files are hidden. So to be able to list the .maintenance file, you will need to use either of the command: $ ls -a OR $ la
STEP 4 – Disable all your wordpress plugins
You will need to login to your wordpress dashboard and manually disabled all plugins
STEP 5 – Backup the current wordpress database of your blog
Here I use the web-based phpmyadmin or you can also use a remote SQL IDE like sqlyog or the free DBeaver to do the export/backup of your db’s sql. I will not go into details in this one.
STEP 6 – Let’s make a check list of what files/folders need to be updated
For any wordpress updates, the following needs to be updated:
- the whole wp-includes folder
- the whole wp-admin folder
- the two default themes (twentyeleven and twentytwelve) residing inside wp-content/themes/
- the default plugins Akismet and hello.php residing inside wp-content/plugins/
- all the wp-(X).php files residing inside your public folder EXCEPT the wp-config.php file
STEP 7 – Let’s copy and overwrite the folder wp-includes
1- Change directory to root folder WWW
2- Let’s copy (recursively):
[lang=’bash’]
$ cp -r wordpress/wp-content/ public/
[/lang]
3- As my rule-of-thumb, I do not need wp-content inside the folder wordpress now, so I will delete it:
[lang=’bash’]
$ rm -rf wordpress/wp-content/
[/lang]
This command will remove recursively this folder and all files/folders in it
STEP 8 – Let’s copy and overwrite the folder wp-admin
1- Follow SAME step as STEP 7 above (but remember to replace wp-includes by wp-admin :P)
STEP 9 – Let’s copy and overwrite the TWO Themes’ folder TwentyEleven & TwentyTwelve
1- Follow SAME step as STEP 7 for each of:
- wp-content/themes/twentyeleven
- wp-content/themes/twentytwelve
STEP 10 – Let’s copy and overwrite the two default plugins Akismet and hello.php
1- Follow SAME step as STEP 7 for each of:
- wp-content/plugins/Akismet
- wp-content/plugins/hello.php
STEP 11 – Let’s copy and overwrite ALL the remaining wp-X.php files inside ‘public’
This is the most easy and also tricky part – But if you do like I’m showing, it’s a breath.
Assuming you have correctly done Step 7 to 10 above, the tree structure of the folder wordpress is now with:
wordpress
├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-cron.php
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php
OBSERVATION:
– Have you noticed something? We are left with ALL the wp-X.php files. 😀 You see where we are going now with the my “delete not used anymore thingy”?
DO:
1- to copy and overwrite all those to our public folder:
[lang=’bash’]
$ cp -r wordpress/wp-content/* public/
[/lang]
The command above is copy/overwrite all files (as denoted by the wildcard *) from within the folder wp-content at wordpress TO the target folder named public
VOILA! Done with the copying and overwriting, let’s now make our blog return to normal.
STEP 12 – Update Your custom plugins
Now if you use other wp plugins and if they are out-dated, you can use the same principle as above to update your plugins.
STEP 13 – browse your blog AND Follow the automated steps
After you have done all STEPs from 7 to 12 above, browse your blog: http://domainName.ext/wp-admin
You will see a message saying you will need to update your Database Structure to use this new updated version of wordpress. Relax, there’s nothing complex to do here apart just “click next, next, next thingy” and you are done! You will now be redirected to your normal dashboard.
STEP 14 – Re-Enable all your plugins
Yep, go ahead and enable all your plugins, BUT one-by-one. Do NOT do bulk-enable!
Why you say? Because you never know what might break with new version. The way I do it, is to enable one plugin at a time and I then test my blog for this plugin to see if all is working as expected. If you encounter any error, you just have to delete this updated plugin and revert to a previous version of it until you fix it or get it fixed by the owner.
STEP 15 – Remove Maintenance mode
Now, go ahead and delete your .maintenance file that we created.
[lang=’bash’]
$ rm .maintenance
[/lang]
But you might also consider just renaming it as .maintenance_bak for later updates 😉
So just rename it:
[lang=’bash’]
$ mv .maintenance .maintenance_bak
[/lang]
This command will simply rename the file .maintenance to .maintenance_bak
Summary Of What We Did To Manually Update WordPress
- Backup your ‘public’ folder where your wordpress engine is found
- Download the latest WordPress source and extract it
- Put your blog into maintenance mode
- Disable all your plugins
- Backup the current wordpress database of your blog
- Overwrite the following folders and files: wp-includes, wp-admin, the default themes, the default plugins and ALL the wp-X.php files
- Update your custom plugins where applicable
- Follow the automated database update for the new version
- Re-Enable all your plugins & test your blog + revert plugins if needed
- Remove Maintenance mode
- Get back to your happy blogging
Possible Side Issues Or Related Reading
- A Glance At What Can Go Wrong Between Your WordPress Installation and MySQL
- How To Get Precise Error Messages For Issues Related To WordPress and MySQL
- How To Change The Path Of Uploading File In WordPress Without Touching The Code Configurations
Over To You!
Thank you for kind attention 🙂 Hope this was useful and insightful. As always I am open to your suggestions. How about You, how do you do it?
PS: If you are having headaches with your wordpress installation, you can hire my services to do your wordpress installation and updates!
Now Do Your Part!
1) LIKE 7PHP dot COM on FaceBook – if you appreciate what I do
2) Help diffuse this article – Share, tweet and spread the word to your audience ==> That would be a FREE way to thank me 😉
3) Make a comment below using the comment form – I’m sure you can at least say 1 word about this article
{I’m thankful to your response(s)!}
Why so many steps?
I just head over to my “upgrade” page and with a click, wordpress updates itself in a few seconds.
If like myself, you can’t update through a browser, you should look into installing wp-cli. It allows you to login through bash (or whatever command line interface you use) and install any updates that are required.