2

i have tried a number of times to get php 5.6 working on ubuntu 16.04

I keep getting a server error 500 when trying to browse http:/domain.com/phpinfo.php to check which version of php is active (server also has 7.0, 7.1, & 7.2)

I also have same error when attempting to run php 7.1 (7.0 & 7.2 are working no problems and i have websites running on the virtualmin server.

I have looked at various answers about this kind of thing here but in all honesty, the answers are often so broken and different i cant find a single procedure that is reliable and works.

Anyone help with this?

For example, will the following ispconfig 3 tutorial, which installs php5.6 in /opt directory, work with virtualmin? ( https://www.howtoforge.com/tutorial/how-to-install-php-5-6-on-ubuntu-16-04/ )

My assumption is that the above tutorial will work and i just need to tell virtualmin where the php 5.6 binaries are located in /opt/? ( see this thread... https://www.virtualmin.com/node/40004 )

adam
  • 75
  • 2
  • 15

2 Answers2

3

By default, Ubuntu 16.04 server assigns the PHP 7.07 or higher version. If you want to allow/assign PHP 5.6 on your server then you will have to install it manually from the following command:

Step 1: Step 1: Update Apt-Get

Linux command: apt-get update && apt-get upgrade.

Step 2: Install PHP 5.6

Install the PHP5.6 repository with these two commands.

Linux command: 
apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install -y php5.6

Step 3: Switch PHP 7.0 to PHP 5.6

Switch from PHP 7.0 to PHP 5.6 while restarting Apache to recognize the change:

a2dismod php7.0 ; a2enmod php5.6 ; service apache2 restart

Verify that PHP 5.6 is running on Apache by putting up a PHP info page. To do so, use the code below in a file named as infopage.php and upload it to the /var/www/html directory.

<? phpinfo(); ?>
2

First add the ppa:ondrej/php repository:

sudo -s  
apt-get update  
apt-get install -y software-properties-common  
add-apt-repository ppa:ondrej/php  

If at this point it throws a CPG error like:

Reading package lists... Done  
W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <THE_KEY>
W: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

..pay attention in the 2nd line showing THE_KEY, then solve with:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <THE_KEY>

Finally:

apt-get update
apt-get install -y php5.6
php -v
Alvaro
  • 11,797
  • 9
  • 40
  • 57
AlexisCaffa
  • 339
  • 3
  • 13
  • is it safe to use ppa on a production server? I have read on other forums one shouldnt use it? – adam Sep 17 '18 at 23:31
  • 1
    Some are better maintained than others. The one being recommended has a pretty good history of reliable maintenance. We use and recommend this one for people who need it (I work on Virtualmin), even though we don't recommend PPAs, in the general case. As always, when using non-core stuff, keep a closer eye on it to make sure it stays up to date. – swelljoe Sep 18 '18 at 11:40