2

I would like to ask a question, regarding whether it is possible to have multiple separate Apache daemons running on the same machine. I do not refer to multiple apache processes. I know this is doable. I am talking about completely separate daemons. I am familiar with the concepts of VirtualHosts, and know how to run multiple websites on the same machine, but this is not what I need.

In detail, I am running a web application on a machine. An apache configuration files directs the web requests to the relevant location, or wsgi app. However, I need to setup a reverse proxy on the same machine. The configuration file of the reverse proxy will be constantly updated with more and more entries. For this reason, I would like to have a separate apache daemon to run the reverse proxy, so that any possible syntax error on the reverse proxy's Apache configuration file, will not affect/crash the web application. First of all, is this the way to go? Or is there another way to isolate the 2 applications(web app, reverse proxy), so that they don't affect each other? If yes, how is it possible?

Thanks in advance.

1
  • Update: Eventually I realized that 2 separate apache daemons will be an overkill. I think it's easy to mess up in that way. Therefore I went for the option of separate config files. Each config file will correspond to a ./deploy script. This script will first validate all apache configuration files (using apachectl configtest) and only if they are all valid, will restart the apache server. Sep 27, 2011 at 13:26

3 Answers 3

1

You can absolutely do this - each daemon needs its own config file and (very important) different TCP ports that they listen on. You can't have multiple processes listening on a single port.

2
  • How is this achieved though? And, when you want to start/stop one of the daemons, how do you specify with one? Sep 26, 2011 at 15:24
  • I've seen it done with parallel install directories - you would have /opt/apache1 and /opt/apache2 (for example). To start/stop, you run the command from the proper directory.
    – mfinni
    Sep 26, 2011 at 15:47
1

You don't need 2 separate daemons, this may be done with port-based virtualhosts.

1
  • What do you mean? Still in this case, an error in one .conf file will affect the other app, right? Sep 26, 2011 at 15:23
1

Sorry, I've read your question inattentively.

If you install apache from source, just install 2 separate installations in 2 separate directories: /opt/apache2_webapp and /opt/apache2_rproxy.

If you want to use package manager, the simpliest way is to install one of servers into chroot. For example, in Debian/Ubuntu there is very convenient Multistrap tool.

If you want to use the same package for running 2 separate servers, you should copy init script, settings directory, pid files directory, log directory, data directory with other names, for example in Debian/Ubuntu:

cp -r /etc/init.d/apache2 /etc/init.d/apache2_rproxy
cp -r /etc/apache2 /etc/apache2_rproxy
cp -r /etc/default/apache2 /etc/default/apache2_rproxy
cp -r /var/run/apache2 /var/run/apache2_rproxy
cp -r /var/log/apache2 /var/log/apache2_rproxy
cp -r /var/www /var/www_rproxy

Then change all paths in new init script and config files, try start/stop new init script to fix possible errors, and add new init script to required runlevels.

P.S. IMHO using 2 separate daemons is overkill. You may set up port-based virtualhost solution, and create script, that will run apache2ctl configtest before each reverse proxy config change and discard this change if test fails.

1
  • Thanks a lot. Very thorough response. I can see it becoming a big mess with 2 Apache instances, so I will try to avoid it :) Sep 27, 2011 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .