I completely dropped phpbrew as it is not intended to switch Apache PHP, just a CLI (by design). This should never have worked, see this is still a function request .
Starts with a clean Cloud9 PHP / Apache cloud desktop. I followed this article How to install PHP 5.6, PHP 7.1 on Ubuntu 16.04, 14.04 using PPA and based on this it happened:
sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install -y php5.6 sudo apt-get install -y php7.2
Then check:
php5.6 -v php7.2 -v
After installing php7.2, I came across:
$ php7.2 -v php7.2: symbol lookup error: php7.2: undefined symbol: pcre_jit_exec
I fixed this by following the advice "Update the libpcre3 library to the version from the repository."
It turns out that it was "hidden", so I had to do this :
apt-get install libpcre3 libpcre3-dev
PHP 7.2 started working! Surprisingly, the original PHP Cloud9 remains untouched, which lives under php5 and can be used at any time. So now I can drag 3 different versions. Yes, phpinfo() shows the version I want every time! Repeated execution of Cloud9 desktop is not even required.
mbstring will be missing for 5.6 (ran into a problem when running phpmyadmin ):
sudo apt-get install php5.6-mbstring
The php.ini files are located at:
sudo find . -name 'php.ini' ./php/7.2/apache2/php.ini ./php/7.2/cli/php.ini ./php/5.6/apache2/php.ini ./php/5.6/cli/php.ini ./php5/fpm/php.ini ./php5/apache2/php.ini ./php5/cli/php.ini
Switching from any to 7.2 PHP
sudo a2dismod php5 sudo a2dismod php5.6 sudo a2enmod php7.2 sudo service apache2 restart
With 1 line:
sudo a2dismod php5 && sudo a2dismod php5.6 && sudo a2enmod php7.2 && sudo service apache2 restart
Switching from anything to 5.6 PHP
sudo a2dismod php5 sudo a2dismod php7.2 sudo a2enmod php5.6 sudo service apache2 restart
With 1 line:
sudo a2dismod php5 && sudo a2dismod php7.2 && sudo a2enmod php5.6 && sudo service apache2 restart
Switching from anything to source PHP from Cloud9
sudo a2dismod php7.2 sudo a2dismod php5.6 sudo a2enmod php5 sudo service apache2 restart
With 1 line:
sudo a2dismod php7.2 && sudo a2dismod php5.6 && sudo a2enmod php5 && sudo service apache2 restart
Now I am very happy.