# multiple apache instances

## na641

Hi all,

I was hoping someone could help me out with a problem. i am trying to figure out how to run two mutually exclusive apache servers on one server. Is there some special trick to doing this? Everything i've tried so far has failed.

----------

## Anarcho

Well, maybe you should specify your "everything".

But in theory you should only need to specify different "Listen" statements for the apache servers that each listens only on exclusive IP addresses.

----------

## PaulBain

If all you want is multiple domains hosted on the same machine you just need apache virtual hosts. ( http://gentoo-wiki.com/HOWTO_Linux_Virtual_Hosting_Server )

I'll assume you actually want two completely seperate apache instances running on the same machine, which will mean you will either need to listen on seperate IP addresses or differet ports.

If you are looking at creating some sort of management system (Plesk or CPanel style) take a look at:

```

Running PHP4 and PHP5 module using 2 Apache instances

If you have one Apache installed, you can run two instances of it. You only need to create a second configuration file (httpd.conf) with different settings (e.g. load PHP5 module, not PHP4 module...). But you cannot bind 2 Apache instances to the same port-IP combination, so you have to use a different IP or port in the 2nd configuration file. At Apache startup you can use the -f switch to set the config file to use, which can be easily implemented by copying and changing the original RC script shipped with the Apache ebuild.

The basic steps to make it work on Gentoo:

    * add apache2 USE flag to dev-lang/php entry in /etc/portage/package.use to install Apache2 modules

    * install PHP4 and PHP5: emerge '=dev-lang/php-4*' '=dev-lang/php-5*'

    * create a copy of /etc/apache2/httpd.conf for the 2nd Apache instance

    * change port or IP the 2nd Apache instance will bind to

    * load other PHP module

    * make sure to use unique files (like LockFile...)

    * copy /etc/init.d/apache2

    * change the copied script to load new (copied and altered) httpd.conf for 2nd Apache instance

Further information:

    * How to run PHP4 and PHP 5 prallel (Tobias Schlitt)

```

http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml

----------

## Inodoro_Pereyra

And also there is the chrooted jail option wich no one is mentioning (Because is the long way  :Very Happy: ) if security is your concern.

Regards.

----------

## na641

Basically the trouble i am having is this:

Every time a new subdomain is added to apache, i have to restart apache before the new sub domain becomes active. Running multiple instances would be a workaround of sorts for this. Does anyone know a more efficient manner to achieve this?

----------

