5

Initial Situation:

I have an Ubuntu 12.04 Server hosting 3 Websites (with Apache 2.2.22)

How can I install a different PHP version for only one of the Websites? (The other 2 should remain as they are)

Current PHP Version: PHP 5.3.10 Desired PHP Version: PHP 5.6.16

What i have done/understood until now:

I have already tried out PHPBrew: http://phpbrew.github.io/phpbrew/

I managed to install PHP 5.6.16 for the command line (with PHPBrew) but the Apache still uses PHP 5.3.10.

I understood that i should end up with an *.so file which i need to place in /etc/apache2/httpd.conf file. (this file is empty at the moment) (via LoadModule...)

But: I don't have any *.so files. I installed PHPBrew like this:

phpbrew install 5.6.16 +default +mysql +mcrypt

I think I should have added +apxs2=/usr/bin/apxs2 but if I do this i get the error "Exception: apxs binary is not executable: /usr/bin/apxs2".

How can i fix this?

Or is there a better way to run different PHP versions on one Server? What is the best way?

4
  • 1
    In order to fix "apxs binary is not executable" i managed to execute sudo apt-get install apache2-dev. I now have the php5.6.16.so file (after re-installing with +apxs2=/usr/bin/apxs2). In etc/apache2/mods-available/php5.load is the new php5.6.16.so file and after a restart of apache2 it worked. Last question remaining is: Is it possible to create a php5.load file for every vhost? Commented Dec 21, 2015 at 17:33
  • When I try, I get this one: The following information may help to resolve the situation: The following packages have unmet dependencies: apache2-dev : Depends: libapr1-dev but it is not going to be installed Depends: libaprutil1-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages. Commented Jul 27, 2016 at 12:42
  • IT seems that that package is not available anymore. Commented Jul 27, 2016 at 12:49
  • Are you sure you don't have .so files? Have you checked /usr/lib/apache2/modules/ ? Commented May 3, 2017 at 10:30

1 Answer 1

1

Double check the .so files, they should be in `/usr/lib/apache2/modules/``

Then you should edit your /etc/apache2/mods-enabled/php5.load and specify the .so file that corresponds to your installation, in your case:

LoadModule php5_module /usr/lib/apache2/modules/libphp5.6.16.so

An alternative solution for running multiple PHP versions on the same box is using Docker, see my answer in another thread: Multiple PHP versions on the same box

Note that with this solution different PHP versions will be available on different ports.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.