Setting 1 Application PHP for multi server

Posted January 25, 2021 576 views
Load BalancingDigitalOcean Droplets

Hello, i wonder if i can use 1 php application with 2 or more server..
i plan to use Cloudflare LB but having 2 same apps in 2 server make the maintenance hard for me.

so i wonder if i can do that.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there @yggitteam,

What you could do is use Lsyncd, for example, to sync the files from your main server to the secondary one.

You can then upload and make all of the changes to the main server, and the changes will be synced over to the second server.

You can follow the steps on how to do that here:

I would recommend having your database hosted on a separate Droplet so that way your two web servers would connect to the same database, and you will not have to worry about data synchronization.

I hope that this helps.

by Justin Ellingwood
While administrating web and application servers, there are many times when it is useful to mirror directories. The lsyncd service can mirror local and remote directories in order to propagate changes from one location to another. This guide will cover the basic usage of this tool.
  • is there any error with php application if i use lsyncd?
    like session error or something

    • Hi there @yggitteam,

      Very good point. Yes, it would be best to set up a caching server like Redis for example and configure your PHP so that it stores the sessions on that shared caching server. Otherwise, your users will lose their sessions every time they hit a different server.