Presently my opportunity includes a 3 server set-up. 2 web boxes behind a lot-balancer and the other box not behind the burden-balancer (employed for Admin, Content management systems and stats). Because of the condition of funds right now we're searching to decommission our single box which isn't behind the burden-balancer. This area has our Content management systems onto it along with a media subdomain indicates /home/web/media on that box. The issue is when we take away the box and port all of the code (PHP) to the burden-balanced web boxes, when personal files is submitted within the Content management systems it'll only upload it towards the media directory from the box the consumer hits. Therefore if a person hits web1 and uploads personal files that file are only available in the /home/web/media directory of web1. So we have to in some way rsync the /media sites on web1 and web2 whenever a file is submitted. Or make a move else.

An amount you recommend to become the easiest method to make this happen?

Any help could be much appreciated.

Only for information reasons we're running PHP 5.2, Red-colored Hat Enterprise Linux and Apache 2..52

Regards,

Owen

Is not it a concept to utilize a network share for that media, so that you can allow it to be on both servers whatsoever time?

You've got a couple of options (some happen to be already pointed out):

  • Store submitted files inside a database (not suggested for files you'll need fast random use of).
  • Make use of a network filesystem for example NFS or SMB, and store submitted files there. (You may also have code copy submitted file towards the other server's filesystem uncovered over NFS or SMB).
  • Make use of a clustered filesystem for example GFS or OCFS.

    function scp($username, $host, $port = 22, $file, $destination)

obviously you'll need that www-data has its own public key on servers and write rights

If you would like the file submitted to both servers in realtime, simply do that.

  1. User uploads personal files on server1.
  2. server1 process the upload and stores it in server1/media.
  3. server1 bakes an authenticated request to server2/api/uploadFile (curl)
  4. server2 process the upload and stores it in server2/media.

Hope which makes sense.