# Is it possible to have two different installations of PHP and Apache on the same machine?

There's a motivation in my company to enable a team of coders to develop an upgraded version of an existing product on one of our development servers. There are two configurations, the one we use now and the new one which is preferred to be installed on a clean slate PHP/Apache installation (but on the same server if possible). My question is, Is it possible to have two different sets of php.ini and httpd.conf on the same server? One will point to the current product and the other will point to the upgraded/updated product..

• Given that servers are incredibly cheap to spin up and rent I think you'd be better off doing just that and keeping them separate. – user9517 Dec 22 '13 at 13:08
• Yeah, I have to go with Iain there: you'll burn through the cost of a cheap VPS in one or two days of labor messing around with this. – Bandrami Dec 22 '13 at 13:36
• Well, I believe I will install some virtual machine now that I understand how wrong it is to that, that's why I asked this question... to see the best method the achieve the goal. – Itai Ganot Dec 22 '13 at 13:39

The -f flag to apachectl lets you start multiple instances with different configurations, e.g.:

apachectl -f /etc/httpd-1.conf start
apachectl -f /etc/httpd-2.conf start


Meanwhile, within the site definitions in those files, the following directive

PHPINIDir /etc/php1


will tell mod_php in the instance you're configuring where to look for php.ini

I'll also tell you from experience you probably don't want to do this for very long.

Now, getting this to work with your system init scripts can be a hassle; IIRC FreeBSD and Debian-derived things make it relatively less painful, but RedHat-derived things less so. Personally, I'd suggest keeping your production server as what the initscripts control, and running the testing server manually with apachectl, etc.