Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple PHP versions using phpenv, php-build and php-version

Tags:

linux

php

apache

I'm on Arch Linux, trying to configure multiple PHP versions for testing my scripts.

I'm basing myself on these three tools:

  • https://github.com/phpenv/phpenv
  • https://github.com/CHH/php-build/
  • http://wilmoore.com/php-version/

First I installed Apache and PHP (and their integration package) with pacman:

# pacman -S php apache php-apache

Next, I followed the instructions for installing the tools on the links, everything is working fine.

I manage to install two versions with phpenv-install from php-build tool. I got something like this:

-- ~
|---.phpenv
  |---lib
  |---versions
    |---5.5.1
    |---5.4.17
  |--- (some more folders)

On CLI environment everything is working fine, I can easily switch between the two versions with php-version:

$ php-version 5.5.1
$ php --version
PHP 5.5.1 (cli) (built: Aug  5 2013 22:54:47) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.2-dev, Copyright (c) 1999-2013, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

$ php-version 5.4.17
$ php --version
PHP 5.4.17 (cli) (built: Aug  5 2013 23:19:44) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Now the problem: integrate this with apache.

As I said in the beginning of this post, I also had to install PHP from Arch repositories, which coincidentally is on version 5.4.17. This installation is working fine with Apache.

On php-env readme there are these instructions:

phpenv support dynamic switching for Apache apxs libraries and install will build and install a libphp5.so shared library for Apache under the versions libexec folder.

By calling phpenv global to show or change the global PHP version a link is created under ~/.phpenv/lib/libphp5.so for the appropriate release build. This link can be used for Apache's LoadModule php5_module directive and requires Apache to restart when changed.

The problem is that there is no file or symlink named libphp5.so in lib directory neither in the whole .phpenv folder, because

$ find ~/.phpenv -name libphp5.so

returns nothing.

Maybe because english is not my first language, I'm having some problem to intepret the second paragraph of the quote above.

like image 412
Henrique Barcelos Avatar asked Jun 11 '26 03:06

Henrique Barcelos


1 Answers

There is a package in the AUR for phpenv https://aur.archlinux.org/packages/phpenv/

As well as packages for many different versions of PHP https://aur.archlinux.org/packages/?O=0&C=0&SeB=nd&K=phpenv&outdated=&SB=n&SO=a&PP=50&do_Search=Go

First install phpenv: yaourt phpenv

Then install the php versions you need, for example: yaourt php53_29_env

Note: even with this though, you will likely have a problem. Checking the package build, it looks like it is missing the patch to disable PHP automatically being compiled with thread safe features when apache is running a thread safe mpm. Not quite sure since on my systems, I want PHP to enable thread safe code so it will work for me.

like image 194
garyamort Avatar answered Jun 13 '26 22:06

garyamort



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!