Are you on a Linux/BSD machine? If so, you can easily use symbolic links to accomplish this goal.
Create Version 1 of the site here:
/var/www/www.example.org.v1
Create a symbolic link pointing to this directory
cd /var/www
ln -s www.example.com.v1 www.example.com
This should give you a directory listing (ls -la
) that looks something like this:
lrwxr-xr-x 1 userid users 18 Aug 3 03:35 www.example.com -> www.example.com.v1
drwxr-xr-x 2 userid users 512 Aug 3 03:35 www.example.com.v1
Set your web server to use /var/www/www.example.com
as its document root. You will never have to change this; all re-pointing will be done at the filesystem level.
Now, when you want to swap in Version 2 of the site all you have to do is place the new version in:
/var/www/www.example.org.v2
And update the symbolic link to point to this version:
ln -sfh www.example.com.v2 www.example.com
Which will leave your directory output looking like this:
lrwxr-xr-x 1 userid users 18 Aug 3 03:43 www.example.com -> www.example.com.v2
drwxr-xr-x 2 userid users 512 Aug 3 03:42 www.example.com.v1
drwxr-xr-x 2 userid users 512 Aug 3 03:41 www.example.com.v2
As you can see, the www.example.com symbolic link is now pointing to Version 2 of your site. This is an atomic operation and should not cause any downtime related to files being unavailable.
Of course, there is still considerable complexity required in ensuring that database structures are updated, any static resources are available (and linked to the correct version), etc, but at least this takes care of making sure that all of the right resources for the new site are instantly available.
Windows Vista and Server 2008 also support symbolic links using the mklink
command, though I don't have any direct experience with them.