Set default PHP version in Ubuntu

To select default PHP version in Ubuntu, run

update-alternatives --config  php

This will show a menu, you can select the default php version

root@server:/usr/bin# update-alternatives --config  php
There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php7.0   70        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.0   70        manual mode

Press  to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/php5.6 to provide /usr/bin/php (php) in manual mode
root@server:/usr/bin#

After setting PHP 5.6 as default PHP version, you will see

root@server:~# php -v
PHP 5.6.40-8+0~20190531120521.15+stretch~1.gbpa77d1d (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
root@server:~# 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *