Phpenv not working

We are running the following as part of a bionic build to add PHP 5.6, however the version of PHP is not changing on the box.

  • sudo add-apt-repository -y ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get -y install php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6
  • sudo update-alternatives --set php /usr/bin/php5.6
  • sudo php -v

sudo update-alternatives --set php /usr/bin/php5.6 this line should install PHP 5.6 as the system version of PHP.

sudo php -v this displays PHP5.6

The first issue is that this isn’t true, the box is running PHP7.

In debug mode:
Another issue is that when I try to run in debug mode, like this post, from 3 years ago, Running phpenv runs rbenv instead - #4 by jmckenna, when I try to run phpenv global 5.6 it returns a message about rbenv:

rbenv: version `5.6’ not installed
The command “phpenv global 5.6” failed and exited with 1 during .

Running apt-get install php5.6, does not fix this, phpenv appears to be overriding any change to PHP that I attempt, and I don’t think it’s possible to remove phpenv as it’s part of the startup script.

I tried changing the version of PHP directly in /home/travis/.phpenv/version but php -v says it’s not installed, even though it has been installed

Any help would be very much appreciated!