Deploying commercial websites without upsetting customers

When deploying updates to a large website (Joomla or Magento sites get pretty big), active clients can be a real pain. Their sessions will break and, at worst, orders or other important data can be lost as files are changed during the deployment.

To avoid these problems, the site is usually taken down for maintenance during the deployment but there is a better way.

A large deployment such as a major version update can take quite a while. It can be accelerated by copying the files elsewhere on the server and then locally copying them but it still involves a significant delay and there remains a risk of error that can result in the site being down for longer than intended.

Larger businesses use staging sites to debug the updates as far as possible but these don't help with the deployment per se. Its still typically necessary to take the site down for a significant amount of time while the updates are deployed and the site is checked... or is it?

The example commands below assume you are using a Debian or Ubuntu server. If you are using a customised server or another flavour of Linux, you will need to adapt the paths and file names appropriately.

Lets just deal with file changes for now. Updates involving database changes will have to stick with the traditional methods for the moment.

For an instant deployment of a significant website revision:

  1. Copy the site files, retaining permissions and ownership, to another folder.

    ~$ sudo cp -a /home/test_site/public_html /home/test_site/public_html_tmp

  2. Change the Apache Virtual Server root for your site to point at the new folder.

    ~$ sudo -i
    root@ws1~# cd /etc/apache2/sites-available
    root@ws1:/etc/apache2/sites-available# cp -a ..
    root@ws1:/etc/apache2/sites-available# sed -i 's:/home/test_site/public_html:/home/test_site/public_html_tmp:g'

  3. Reload Apache.

    root@ws1:/etc/apache2/sites-available# service apache2 reload

  4. If you are using something like Magento that may have linked sites using the same files, make sure that you also update any linked sites to point to your temporary site folder. If you are paranoid like me, you'll write a little script to do this so you know you have remembered everything before you do it for real.
  5. Deploy the changes to the original site files

    You would generally do this with FTP using Filezilla or perhaps something like Springloops (which in turn uses FTP).

  6. You can do a sanity check of the deployment by pointing another virtual server at the changed folder if you need to. Don't confuse this with a staging site though because its dealing with the real live site database so any changes or purchases made will be real.
  7. Change the Apache Virtual Server root back to pointing at your site again.

    root@ws1~# cd /etc/apache2/sites-available
    root@ws1:/etc/apache2/sites-available# mv ../ .

  8. Restore the links for any of your linked websites.
  9. Reload Apache.

    root@ws1:/etc/apache2/sites-available# service apache2 reload

This way you don't have to close the site at all. After an appropriate delay (depending upon your session timeouts and visitor staying time - 24 hours should be more than enough) you can delete the copy and everything is as it was except that the site is updated without any interruption to service.


There are currently no comments

New Comment


required (not published)


Australia: 07 3103 2894

International: +61 410 545 357