Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to replicate my virtual machine and put it behind a load balancer.

Apache1  Apache2 ....ApacheN
   |        |           |
-------------------------
        LoadBalancer

I'd like to use only ONE configuration file for virtual hosts (actually a directory of conf files with Include in each httpd.conf), ONE log file and a common DocumentRoot directory for all instances. Is that possible, just sharing some directory between the virtual machines and configuring each Apache accordingly?

Or there will be some conflict with file opening and writing?

Is there maybe a better way of maintaining all the machines with the same configuration?

The only other thing I can think of, it's a script that copies a master configuration and restarts all the Apache instances. And also some script to merge all the logs...

Any suggestion welcome.

PS sorry for posting this first on stackoverflow, where it is in hold and doesn't get moved here...

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You may well share the apache config and document root among many identical machines - no problem to use e.g. an NFS share for these purposes.

It would be wise not to share the apache log directories because on heavy load you will get many concurrent writes. In one setup I used remote syslogging to get common apache logs. This will be a separate question how to achieve this. See http://httpd.apache.org/docs/2.2/mod/core.html as a starting point for the sender side.

You will have to configure your (server's local) syslog accordingly.

share|improve this answer

Is there maybe a better way of maintaining all the machines with the same configuration?

Yes, a configuration management system (Puppet, Chef, ...) is the proper way of dealing with this.
They can automatically deploy updated configuration files and restart the services afterwards.
Logs should be sent via (r)syslog to a central logging server.

As for the content of the DocumentRoot: that depends on what is in there.
If it is static code, then packaging it and deploying it via the standard OS tools (yum, apt-get, ...) would be preferable.
It also makes it easier to roll out new versions slowly.

It is of course possible to have a file share but this may act as a single point of failure then.
And it will be painful to check which machine already restarted the service after a new config has been placed there as you add more servers.

share|improve this answer

Your Answer

 
discard

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.