Synchronize files between PHP servers

There is a file sync feature on the Easy (Jelastic) road map but until then we can help you to achieve this now.
You need this if you plan to have more than one load balanced PHP servers with locally stored files that needs to be available on all PHP servers. Examples are Drupal and Wordpress sites with user generated content in Blogs.

The solution is to use a VDS node for central point of storage and all PHP servers will update the files to and from the VDS.

1. Create a PHP Environment with one application server and one VDS.

2. Contact our support and we will set up a ssh trust between the PHP server and the VDS.

3. Add a cron job that will sync the files you 
This example will sync the files every second minute. Replace the IP address with the IP of your VDS:
*/2 * * * * rsync -au /var/www/webroot/ROOT/* 88.80.172.87:/home/nginx/ROOT/ > /dev/null 2>&1; sleep 10; rsync -au 88.80.172.87:/home/ROOT/* /var/www/webroot/ROOT/ > /dev/null 2>&1

4. Now you can add more PHP servers the the Environment and all servers will sync the selected files between each other.

Note:
Files will never be deleted. If a file is deleted on a server the file will be copied back again from the other server.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.