Multiple Apache instances -- how?

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Multiple Apache instances -- how?

Post by alex.barylski »

I need to run a separate instance of Apache configured to minimize security issues. I have read this is possible several times but have not seen a example of how this is done...

I assume you simply start a new Apache daemon and point it to a new configuration file (httpd.conf) and bind to a port other than 80?

Can someone give me the basics as to how this is done as well as show me the commands I might execute?

For example:

Code: Select all

apache2 somenew.config.file -p 8088
Is something like the above how I might start a new Apache daemon which served requests over port 8088?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Multiple Apache instances -- how?

Post by Chris Corbyn »

I've only ever done it by compiling two self-contained versions into /usr/local. What do you need this for again? Can you elaborate on the security issues you envisage? If it's anything to do with user permissions look at PHP/CGI/SuExec.

EDIT | Also, many of the config settings you might change on a per-host basis are settable from within a <VirtualHost>, <Directory> or <Location> directive.
Doug G
Forum Contributor
Posts: 282
Joined: Sun Sep 09, 2007 6:27 pm

Re: Multiple Apache instances -- how?

Post by Doug G »

If you want to see an operating example you could install ispconfig on a server. ISPConfig compiles and installs it's own apache in it's own directory with it's own conf file, and on port 81.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Multiple Apache instances -- how?

Post by VladSun »

Apache 2.* for Debian:
copy /etc/apache2/apache2.conf directory to /etc/apache2_8080 for example
Edit /etc/apache2_8080/apache2.conf (and included files) so it conforms your needs, but you must have this done:
- change in "/etc/apache2_8080/apache2.conf " line "ServerRoot /etc/apache2/" to "ServerRoot /etc/apache2_8080/";
- change in "/etc/apache2_8080/apache2.conf " line "PidFile /var/run/apache2.pid" to "PidFile /var/run/apache2_8080.pid";
- change in "/etc/apache2_8080/ports.conf" to "Listen 8080"

Then run

Code: Select all

apache2 -f /etc/apache2_8080/apache2.conf  -k start
That's it :)
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Multiple Apache instances -- how?

Post by alex.barylski »

I've only ever done it by compiling two self-contained versions into /usr/local
Hmm...why did you need two installations of Apache? All modules in my current installation are loaded via config files...so I thought using the same copy of Apache would suffice.
Can you elaborate on the security issues you envisage
Using apache as a substitute to FTP and the book recommends running it as such. Basically to remove all the modules otherwise dynamically loaded. I know I can disable PHP with a directive in .htaccess but running under a resitrcted environment is probably best.

VladSun: Thats the setup I was looking for. I thought it might be possible to do that but I wasn't sure. Thanks for that. :)
Post Reply