I have to compile a few versions of PHP in work but I need an apache service for each version running like we have on Windows. However the configure options seem to have different folders for everything. I was wondering if there was an easy way to configure so when I make install it is all in one folder, with all the extensions in ext etc rather than scattered around the system.

I want to compile 5.5.1, 5.3.27, 5.2.17 and 4.3.11.

Now this wouldn't be a problem with just one PHP version but with multiple versions things will probably be overwritten/conflicted in other ways.

Say I want everything to go to /php/5.5.1/

./configure --prefix=/php/5.5.1/

How else is this to be configured to put everything in that folder? Has anyone else done this?

  • Do you have to manually compile them? What distro are you using, and doesn't it have packages for the various versions? Aug 5, 2013 at 10:31
  • I'm using mint and I've searched the default repos and they only seem to have one version. I've searched for php linux binaries on google to no avail. I'm guessing I have to compile them unless there is some good trusted repo which has many versions? Aug 5, 2013 at 11:12
  • 1
    Don't install under /php/5.5.1. Install under /opt/php/5.5.1, that's what /opt is for (a bit like Program Files in Windows). Aug 5, 2013 at 22:40

2 Answers 2


The --prefix will make sure all man pages, config files and includes are compiled in that location. The --exec-prefix will do the same only for executables and extensions

./configure --prefix=/php/5.5.1/ --exec-prefix=/php/5.5.1//exec
  • So ./configure --prefix=/php/5.5.1/ --exec-prefix=/php/5.5.1/exec should pack every file into /php/5.5.1/? Aug 5, 2013 at 11:11
  • 1
    Except for the Apache module all files will go there.
    – tlenss
    Aug 5, 2013 at 11:43

You might want to try using phpbrew instead of installing these your self. phpbrew is a frontend that can help with the managing, switching and compiling of different versions of PHP. It works similarly to perlbrew for Perl.


To see what versions you have setup:

$ phpbrew known
Available stable versions:

To install a version:

$ phpbrew -d install --test php-5.4.0

To use a version:

$ phpbrew use php-5.4.0RC7

To make your default a different version:

$ phpbrew switch php-5.4.0

What about Apache

phpbrew can provide you the ability to include variants, so that you can include things such as mysql support or Apache support (apxs).

$ phpbrew install php-5.3.10 +mysql +apxs2

If you have you'r own version of Apache installed, you can direct phpbrew to it's location:

$ phpbrew install php-5.3.10 +mysql +apxs2=/usr/local/bin/apxs2

You'll need to maintain different versions of Apache httpd.conf files for each individual PHP, if you're using it with a web server.

  • I'll have a look into this thanks :) The other answer seems more simple and would allow me to setup different apaches pointing to different php inis on different ports. But I'll see if this can too? Aug 5, 2013 at 11:15
  • 1
    @foxyfennec - this could be done with phpbrew too. After you set it up all your PHP's will be self contained as well. You can point into this tree for the various php.ini files.
    – slm
    Aug 5, 2013 at 11:32

You must log in to answer this question.

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