Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I setup multiple PHPs in linux? How do use a version depending on the project I'm working on?

I had to ask because I'm still using PHP 5.2.* and I'd like to test if migrating my projects to PHP 5.3 would not introduce problems without messing with my current PHP version.

I'm using Fedora 10/11.

Edit Another reason for having 2 versions at the same time is that one project should be done in PHP 5.2.* while the other is on PHP 5.3. Both being developed at the same time.

Virtual Machine is not an option since I have a limited hard disk space.

share|improve this question

Why not do things inside a virtual machine and experiment?

If that is not an option, you must not use the package manager to install it. This will upgrade and overwrite the existing version.

You can download php and install it manually inside a user directory, such as /usr/local/php53 instead. Then, start up a new web-server instance (listening on port 8080 or other) that uses the php executable in here.

You should be able to specify which php instance to load in the web-server configurations and also the appropriate php.ini configuration file to use (instead of the default system-wide one).

share|improve this answer
Start a new web server instance? How do I do that with httpd? Could you specify which parts of the web server configs and php.ini needs modifying? – Randell Sep 9 '09 at 2:08
You do not even need to use apache nor modify the existing php.ini to make this work. Just use something like lighttpd and change the php-cgi path in the settings. – sybreon Sep 9 '09 at 4:13

Sybreon is correct, your best bet is to try it in a virtual machine, or something like a cheap slice from slicehost. If you can't do that, build your own PHP from source. Make sure you use the --prefix option when you run ./configure from the source tarball.

share|improve this answer
What's the purpose of the --prefix? I'd like to achieve the setup without having to create a Virtual Machine. My hard disk space is limited. – Randell Sep 9 '09 at 3:18
--prefix makes sure you're not overwriting the default binaries. --prefix=/opt/mycustomphp/ will make sure php binaries are installed in /opt/mycustomphp/bin , this way /usr/bin/php doesn't get overwritten – Vid Luther Sep 9 '09 at 3:31

An easy way: in your phpinfo you're able to see "config" line. Just copy it, and build a new php version in another directory:

./configure (copied line here)

Don't do "make install"! Now you have a compiled php in the same directory ("./bin", maybe?). Just make symlinks and enjoy

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.