Reputation: 1512
I have installed PHP 7 on Ubuntu:
php -v
PHP 7.0.5-2+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
It appears that right version is loaded:
php -i | grep "Loaded Configuration File"
Loaded Configuration File => /etc/php/7.0/cli/php.ini
However phpinfo() still reports old version:
PHP Version 5.5.9-1ubuntu4.14
How do I change it? Thanks!
This is OS version:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
I am trying to run latest Magento 2 from Git
Upvotes: 2
Views: 3100
Reputation: 55
From PHP 5.6 To PHP 7.1
$ sudo a2dismod php5.6
$ sudo a2enmod php7.1
$ sudo service apache2 restart
$ update-alternatives --set php /usr/bin/php7.1
From PHP 7.1 to PHP 5.6
$ sudo a2dismod php7.1
$ sudo a2enmod php5.6
$ sudo service apache2 restart
$ sudo update-alternatives --set php /usr/bin/php5.6
Upvotes: 0
Reputation: 1280
I was wondering the same thing while working on different versions of Silverstripe...
Dhivin's answer was very close, but was missing out a couple of extra changes for PHP CLI. The lines that worked for me were:
From PHP 7.0 to 5.6
sudo update-alternatives --set php /usr/bin/php5.6
From PHP 5.6 to 7.0
sudo update-alternatives --set php /usr/bin/php7.0
Add the above lines to Dhivin's answer, and it should work for you :).
Upvotes: 2
Reputation: 706
for enabling php5 to php 7 after install
sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart
for enabling php7 to php 5 after install
sudo a2dismod php7.0
sudo a2enmod php5.6
sudo service apache2 restart
Upvotes: 3
Reputation: 1781
To install PHP 7 on Ubuntu 14, enter the following commands in the order shown:
sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update
sudo apt-get install -y php7.0 libapache2-mod-php7.0 php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-zip php7.0-bcmath php7.0-iconv
Enter the following command to verify PHP 7 installed properly:
php -v
Upvotes: 0
Reputation: 334
You can purge all php and install new
sudo aptitude purge dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
or just disable unnecessary php module and enable php7
see there https://stackoverflow.com/a/38230807/1893211
Upvotes: -1