PHP Upgrade – PHP 5.5 to 5.6 or 7.0

Problem

You need to upgrade PHP from 5.5 to 5.6 or 7.0

Solution

From the command line type

# add-apt-repository ppa:ondrej/php
# apt-get update
# apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0 php5.6-curl php5.6-gd php5.6-mcrypt php5.6-xml php5.6-xmlrpc

Switch PHP v5.6 to PHP v7.0

# sudo a2dismod php5.6 && sudo a2enmod php7.0 && sudo service apache2 restart
# sudo ln -sfn /usr/bin/php7.0 /etc/alternatives/php

Switch PHP v7.0 to PHP v5.6:

# sudo a2dismod php7.0 && sudo a2enmod php5.6 && sudo service apache2 restart
# sudo ln -sfn /usr/bin/php5.6 /etc/alternatives/php

To add additional features

# sudo apt-get install libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json

If you have issues disabling the old version, try

a2dismod php5

to enable v7 try:

a2enmod php7.0

Tested Platform
PHP 5.5, 5.6, 7.0
Ubuntu

Hits: 1

Leave a Reply