HOWTO: Update WordPress with Minimal Downtime
All Things Marked runs on the WordPress blogging platform. Honestly, what blog doesn’t? WordPress often has updates to the code, which involves completely updating files that run the site. Many blogs need to take their sites down for a bit to deal with the update process, however, this process can be completely done within 5 minutes. I’ll give you some tips on how to systematically update WordPress while keeping a professional look to the site. Let’s get at it so you can use this method for your next update.
1. Create a “We’ll be right back” landing page
The first thing you need to do is to create a landing page for visitors to see when you are in the update process. This should be a very simple page that says something like, “[site name] is updating right now and will be back in a flash.”
I’ve created such a page at allthingsmarked.com/updatingwp.html
It’s simple and to the point. One thing that I’ve done which I recommend is to add a refresh meta tag that will refresh the site in 5 minutes. The whole update process should take 5 minutes or less, so if you auto-refresh the page for your visitor after 5 minutes, they will see the site back in action. To do this, just add the following meta tag:
<meta http-equiv="refresh" content="300;url=http://www.allthingsmarked.com" />
Obviously you need to change the domain. The 300 is the time in seconds, which means 5 minutes.
2. Create alias commands (if you have shell access)
If you have shell access to your server, SSH in and open up your aliases file. I’m not a linux guru, but I believe this file varies for each distro. My file is the
.aliases file in my home folder. Open it up and add two new aliases, one to swap in the landing page, the other to revert to the original home page.
We want to rename the live site’s index to a backup of it and then rename the landing page to index. This will “take the site down” by making all requests go to this new home page. Don’t worry though, you still have the backed up live site index. At this point, you would then transfer your update files. Once your done with the update, you want to undo the renaming of files. Here are the two commands you need:
alias startwpu 'mv ~/site_path/index.php ~/site_path/index-backup.php && mv ~/site_path/updatingwp.html ~/site_path/index.html'
alias stopwpu 'mv ~/site_path/index.html ~/site_path/updatingwp.html && mv ~/site_path/index-backup.php ~/site_path/index.php'
startwpu command you are creating will rename the real index file to another name, then it will rename the landing page to the index. The
stopwpu will do the opposite: rename the index to the landing page then rename the backed up index to index.
3. Upgrade WordPress
Once you have the landing page set up and the appropriate aliases, you can update your site.
1. On the command line run the new
2. Transfer all of the files in the new version of WordPress EXCEPT index.php (save that till the end!)
3. Once all files except index.php are transfered, run
stopwpu— this will bring back the real index.php
4. Now, transfer the new index.php from the upgrade files and it will overwrite the “old” one
5. Go to your-site.com/wp-admin/upgrade.php and finish the process
6. At this point, 5 minutes should not have passed, unless you have a slower connection
Your visitors in that 5 minutes while have the landing paging standing by to redirect them. Feel free to adjust the refresh rate based on your typical backup time length.