This tutorial introduce a effortless way to build a distributed dynamic scripting website between Linux servers in two different zone.
To build up a dynamic website mirror for different zone/region/country without using Content Delivery Network, you should consider:
- File Synchronization
- Database Synchronization
- Region Detection And Redirection
Step one: File Synchronization
We will use rsync for file synchronization
rsync --progress --stats --compress --rsh=/usr/bin/ssh --recursive --times --perms --links --exclude "*bak" --exclude "*~" --exclude "config.php" /var/www/path/* DESTINATION:/var/www/path/
It is recommended to create a batch file & run this command every 5 minutes, you may need to detect if rsync is already running, checkout here to find out how to detect if a process is already running. You may have muptiple hosts, yet the principle should be the same.