2

After I have updated php5 to/and installed PHP 7.

When I run php -v:

PHP 7.0.23-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Aug 31 2017 12:52:39) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache **v7.0.23**-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

But my phpinfo() still on :

PHP Version 5.5.31-2+deb.sury.org~trusty+1

What should I do to work on PHP7 and not PHP5?

LeonardChallis
  • 7,759
  • 6
  • 45
  • 76
KJA
  • 743
  • 3
  • 9
  • 21
  • Related? [Ubuntu 14.04: Upgrade to php7 and uninstall php5?](https://stackoverflow.com/questions/40611976/ubuntu-14-04-upgrade-to-php7-and-uninstall-php5) – FirstOne Sep 18 '17 at 13:35
  • If you don't need to have the two differents versions of PHP in your server you should remove the PHP5. Or if you want to have both you have to configure Apache conf file to know which one it has to use. – Vindic Sep 18 '17 at 13:40
  • @Vindic I don't need the PHP5 and I did run $ apt-get update && apt-get purge php5-fpm && apt-get --purge autoremove && apt-get install php7.0-fpm php7.0-mysql php7.0-curl php7.0-gd php7.0-json php7.0-mcrypt php7.0-opcache php7.0-xml nothing changed – KJA Sep 18 '17 at 13:44

2 Answers2

5

It is because your PHP CLI version is 7 but web is using 5.5

From php5.x to php7.0:

Web:

sudo a2dismod php5.x ; sudo a2enmod php7.0 ; sudo service apache2 restart

CLI:

sudo update-alternatives --set php /usr/bin/php7.0

From php7.0 to php5.x:

Web:

sudo a2dismod php7.0 ; sudo a2enmod php5.x ; sudo service apache2 restart

CLI:

sudo update-alternatives --set php /usr/bin/php5.x

In place of x you have to use particular version ex 5.6

BSB
  • 2,270
  • 17
  • 26
  • PHP Version 5.5.31-2+deb.sury.org~trusty+1 I should replace it only with 5.5. right? – KJA Sep 18 '17 at 13:49
  • ERROR: Module php5 is enabled - cannot proceed due to conflicts. It needs to be disabled first! – KJA Sep 18 '17 at 13:52
  • yes or directly you can enable 7.0 using `sudo update-alternatives --set php /usr/bin/php7.0` for web, if installed. – BSB Sep 18 '17 at 13:53
  • Thanks. this helped me. https://stackoverflow.com/questions/35988990/how-to-enable-php7-module-in-apache – KJA Sep 18 '17 at 13:54
0

Easiest command with recommended php-apache modules -

//update/upgrade from php5 or php7.0 to php7.1

php -v

sudo apt install python-software-properties

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt install php7.1

sudo apt install php7.1-cli php7.1-xml php7.1-mysql

sudo update-alternatives --set php /usr/bin/php7.1

sudo apt-get install php7.1-gd

sudo apt-get install php-mbstring php7.1-mbstring php-gettext libapache2-mod-php7.1

sudo apt-get install php7.1-json

sudo apt-get install php7.1-soap

sudo service apache2 restart

sudo a2dismod php7.0

sudo a2enmod php7.1

sudo service apache2 restart

php -v
Cristik
  • 30,989
  • 25
  • 91
  • 127
Rakesh Mali
  • 29
  • 1
  • 3