Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a little new to PHP and EC2 so bear with me. I need to setup two instances on EC2 running Apache and PHP, that in turn communicate with a third instance running MySQL server. The two Web instances will sit behind a load balancer.

1) How do I synchronize the files (php, conf, etc) in the different web server instances? What is the standard practice for doing such synchronization in a Web server farm and can this be simplified by running on EC2?

2) Most Web application architectures contain a presentation layer, business logic layer and the storage layer. Is there such an application server for PHP where I can continue to use Apache as a front end web server? (for example, running EJBs on JBoss and using Apache as the front end web server). Does the Apache/PHP solution scale well enough?



share|improve this question

I can answer (1) but not so knowledgeable on (2):

1) File synchronization is a problem that usually has a range of solutions that depend on the specific technologies you're using. I've used DFS on Windows and that seems to work quite well. On a *nix system, you might be better off using something like rsync on a cronjob, depending on your requirements. I don't think there's anything specific about EC2 that would make this easier though.

2) I'm not a PHP expert, but I would have thought that running a PHP-based webservice sat behind Apache (or your webserver of choice) would be a commonly used middle-tier in an n-tier architecture. It mostly depends on how you want your front- and mid-tiers to communicate, be it HTTP or some sort of EMS. PHP seems to fit the web/HTTP mould rather well, so I'd suggest looking at the webservice path.

share|improve this answer
lsyncd is probably a far better solution then rsync and a cronjob. – devicenull Apr 6 '11 at 3:10

1) Unfortunately there's nothing that comes close to being a "standard" but most sites get by with NFS or rsync (or a combination). Lately farming out a subset (the conf) to puppet has become more popular. So for instance your php.ini would be controlled via puppet, your code would be pushed out via rsync, and your user uploads or pre-generated static files would be on NFS.

2) most php apps are firmly rooted in the single-http-request/sub-300-millisecond lifecycle. That said, you absolutely could have a separate jboss tier or any other long-lived/memory-resident application server. Just have your php code call back to it via http or thrift or the like.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.