How to Change the Default Version of PHP (7.2) on Ubuntu 19.04
- 00:15 How to change the default version of PHP (7.2) On Ubuntu 19.04
- 00:24 add-apt-repository ppa:ondrej/php
- 00:35 php -v
- 00:44 apt install php5.6 -y
- 00:51 apt install php5.6-mysql php5.6-simplexml php5.6-gd php5.6-mcrypt -y
- 01:01 apt install php7.0 -y
- 01:09 apt install php7.0-mysql php7.0-simplexml php7.0-gd php7.0-mcrypt -y
- 01:14 php -v
- 01:26 update-alternatives --set php /usr/bin/php5.6
- 01:29 php -v
Change the default version of php 7.2 On Ubuntu 19.04
Update the apt repository by executing the following command
root@linuxhelp:~# apt update
Hit:1 http://security.ubuntu.com/ubuntu disco-security InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu disco InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu disco-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu disco-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
132 packages can be upgraded. Run 'apt list --upgradable' to see them.
Add the repository to install the different versions of php
root@linuxhelp:~# add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.
Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa
You can get more information about the packages at https://deb.sury.org
BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting
CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advise to add ppa:ondrej/nginx-mainline
or ppa:ondrej/nginx
PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/
WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
#LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or Ctrl-c to cancel adding it.
Hit:1 http://in.archive.ubuntu.com/ubuntu disco InRelease
Hit:2 http://security.ubuntu.com/ubuntu disco-security InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu disco-updates InRelease
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu disco InRelease [20.8 kB]
Hit:5 http://in.archive.ubuntu.com/ubuntu disco-backports InRelease
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu disco/main amd64 Packages [37.5 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu disco/main i386 Packages [37.5 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu disco/main Translation-en [16.8 kB]
Fetched 113 kB in 3s (43.9 kB/s)
Reading package lists... Done
Check the default version of php
root@linuxhelp:~# php -v
PHP 7.2.17-0ubuntu0.19.04.1 (cli) (built: Apr 18 2019 18:01:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.17-0ubuntu0.19.04.1, Copyright (c) 1999-2018, by Zend Technologies
Install the php version 5.6 as follows
root@linuxhelp:~# apt install php5.6 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php5.6 php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline
The following NEW packages will be installed:
libapache2-mod-php5.6 php5.6 php5.6-cli php5.6-common php5.6-json php5.6-opcache php5.6-readline
0 upgraded, 7 newly installed, 0 to remove and 160 not upgraded.
.
.
.
.
.
libapache2-mod-php5.6: php7.2 module already enabled, not enabling PHP 5.6
Setting up php5.6 (5.6.40-8+ubuntu19.04.1+deb.sury.org+1) ...
Processing triggers for man-db (2.8.5-2) ...
Install the required modules of php5.6 in the below given way.
root@linuxhelp:~# apt install php5.6-mysql php5.6-simplexml php5.6-gd php5.6-mcrypt -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php5.6-xml' instead of 'php5.6-simplexml'
php5.6-mcrypt is already the newest version (5.6.40-8+ubuntu19.04.1+deb.sury.org+1).
.
.
.
Creating config file /etc/php/5.6/mods-available/xsl.ini with new version
Setting up php5.6-gd (5.6.40-8+ubuntu19.04.1+deb.sury.org+1) ...
Creating config file /etc/php/5.6/mods-available/gd.ini with new version
Processing triggers for libapache2-mod-php5.6 (5.6.40-8+ubuntu19.04.1+deb.sury.org+1) ...
Install another php version 7.0 as follows:
root@linuxhelp:~# apt install php7.0 -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
The following NEW packages will be installed:
libapache2-mod-php7.0 php7.0 php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 7 newly installed, 0 to remove and 160 not upgraded.
Need to get 3,669 kB of archives.
After this operation, 14.2 MB of additional disk space will be used.
.
.
.
.
.
Creating config file /etc/php/7.0/cli/php.ini with new version
Setting up libapache2-mod-php7.0 (7.0.33-8+ubuntu19.04.1+deb.sury.org+1) ...
Creating config file /etc/php/7.0/apache2/php.ini with new version
libapache2-mod-php7.0: php7.2 module already enabled, not enabling PHP 7.0
Setting up php7.0 (7.0.33-8+ubuntu19.04.1+deb.sury.org+1) ...
Processing triggers for man-db (2.8.5-2) ...
Install the php modules of 7.0 version by executing the following command.
root@linuxhelp:~# apt install php7.0-mysql php7.0-simplexml php7.0-gd php7.0-mcrypt -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'php7.0-xml' instead of 'php7.0-simplexml'
The following NEW packages will be installed:
php7.0-gd php7.0-mcrypt php7.0-mysql php7.0-xml
0 upgraded, 4 newly installed, 0 to remove and 160 not upgraded.
Need to get 289 kB of archives.
After this operation, 1,240 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu disco/main amd64 php7.0-gd amd64 7.0.33-8+ubuntu19.04.1+deb.sury.org+1 [28.3 kB]
.
.
.
.
Creating config file /etc/php/7.0/mods-available/mysqlnd.ini with new version
Creating config file /etc/php/7.0/mods-available/mysqli.ini with new version
Creating config file /etc/php/7.0/mods-available/pdo_mysql.ini with new version
Processing triggers for libapache2-mod-php7.0 (7.0.33-8+ubuntu19.04.1+deb.sury.org+1) ...
Now lets check the version of php after the installation of two php versions 5.6 and 7.0
root@linuxhelp:~# php -v
PHP 7.2.17-0ubuntu0.19.04.1 (cli) (built: Apr 18 2019 18:01:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.17-0ubuntu0.19.04.1, Copyright (c) 1999-2018, by Zend Technologies
Set the default versions of php as 5.6 by using alternatives utility .
root@linuxhelp:~# update-alternatives --set php /usr/bin/php5.6
update-alternatives: using /usr/bin/php5.6 to provide /usr/bin/php (php) in manual mode
Check the default version of php after setting.
root@linuxhelp:~# php -v
PHP 5.6.40-8+ubuntu19.04.1+deb.sury.org+1 (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
With this,Default php version 7.2 On Ubuntu 19.04 has been changed successfully .
Comments ( 0 )
No comments available