How you can Set up Totally different PHP (5.6, 7.Zero and seven.1) Variations in Ubuntu

PHP (recursive acronym for PHP: Hypertext Preprocessor) is an open-source, fashionable general-purpose scripting language that’s widely-used and finest suited to creating web sites and web-based purposes. It’s a server-side scripting language that may be embedded in HTML.

Presently, there are three supported variations of PHP, i.e PHP 5.6, 7.0, and eight.0. Which means PHP 5.3, 5.4, and 5.5 have all reached the tip of life; they’re now not supported with safety updates.

On this article, we are going to clarify the right way to set up all of the supported variations of PHP in Ubuntu and its derivatives with essentially the most requested PHP extensions for each Apache and Nginx internet servers utilizing an Ondřej Surý PPA. We can even clarify the right way to set the default model of PHP for use on the Ubuntu system.

Be aware that PHP 7.x is the supported secure model within the Ubuntu software program repositories, you’ll be able to affirm this by working the apt command under.

$ sudo apt present php
OR
$ sudo apt present php -a

Present PHP Model Info

Package deal: php
Model: 1:7.0+35ubuntu6
Precedence: non-obligatory
Part: php
Supply: php-defaults (35ubuntu6)
Origin: Ubuntu
Maintainer: Ubuntu Builders <[email protected]>
Authentic-Maintainer: Debian PHP Maintainers <[email protected]>
Bugs: https://bugs.launchpad.internet/ubuntu/+filebug
Put in-Measurement: 11.Three kB
Relies upon: php7.0
Supported: 5y
Obtain-Measurement: 2,832 B
APT-Sources: http://archive.ubuntu.com/ubuntu xenial/essential amd64 Packages
Description: server-side, HTML-embedded scripting language (default)
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
open supply general-purpose scripting language that’s particularly suited
for internet growth and will be embedded into HTML.
.
This package deal is a dependency package deal, which will depend on Debian’s default
PHP model (presently 7.0).

To put in the default PHP model from the Ubuntu software program repositories, use the command under.

$ sudo apt set up php

Set up PHP (5.6, 7.x, 8.0) on Ubuntu Utilizing PPA

1. First begin by including Ondřej Surý PPA to put in completely different variations of PHP – PHP 5.6, PHP 7.x, and PHP 8.Zero on the Ubuntu system.

$ sudo apt set up python-software-properties
$ sudo add-apt-repository ppa:ondrej/php

Add PPA in UbuntuAdd PPA in Ubuntu

2. Subsequent, replace the system as follows.

$ sudo apt-get replace

3. Now set up completely different supported variations of PHP as follows.

For Apache Net Server

$ sudo apt set up php5.6 [PHP 5.6]
$ sudo apt set up php7.0 [PHP 7.0]
$ sudo apt set up php7.1 [PHP 7.1]
$ sudo apt set up php7.2 [PHP 7.2]
$ sudo apt set up php7.3 [PHP 7.3]
$ sudo apt set up php7.4 [PHP 7.4]
$ sudo apt set up php8.0 [PHP 8.0]

For Nginx Net Server

$ sudo apt set up php5.6-fpm [PHP 5.6]
$ sudo apt set up php7.0-fpm [PHP 7.0]
$ sudo apt set up php7.1-fpm [PHP 7.1]
$ sudo apt set up php7.2-fpm [PHP 7.2]
$ sudo apt set up php7.3-fpm [PHP 7.3]
$ sudo apt set up php7.4-fpm [PHP 7.4]
$ sudo apt set up php8.0-fpm [PHP 8.0]

4. To put in any PHP modules, merely specify the PHP model and use the auto-completion performance to view all modules as follows.

———— press Tab key for auto-completion ————
$ sudo apt set up php5.6
$ sudo apt set up php7.0
$ sudo apt set up php7.1
$ sudo apt set up php7.2
$ sudo apt set up php7.3
$ sudo apt set up php7.4
$ sudo apt set up php8.0

Search PHP ModulesSearch PHP Modules

5. Now you’ll be able to set up most required PHP modules from the checklist.

———— Set up PHP Modules ————
$ sudo apt set up php5.6-cli php5.6-xml php5.6-mysql
$ sudo apt set up php7.0-cli php7.0-xml php7.0-mysql
$ sudo apt set up php7.1-cli php7.1-xml php7.1-mysql
$ sudo apt set up php7.2-cli php7.2-xml php7.2-mysql
$ sudo apt set up php7.3-cli php7.3-xml php7.3-mysql
$ sudo apt set up php7.3-cli php7.4-xml php7.4-mysql
$ sudo apt set up php7.3-cli php8.0-xml php8.0-mysql

6. Lastly, confirm your default PHP model used in your system like this.

$ php -v

Check Default PHP Version in UbuntuTest Default PHP Model in Ubuntu

Set Default PHP Model in Ubuntu

7. You possibly can set the default PHP model for use on the system with the update-alternatives command, after setting it, verify the PHP model to substantiate as follows.

———— Set Default PHP Model 5.6 ————
$ sudo update-alternatives –set php /usr/bin/php5.6

Set PHP 5.6 Version in UbuntuSet PHP 5.6 Model in Ubuntu
———— Set Default PHP Model 7.0 ————
$ sudo update-alternatives –set php /usr/bin/php7.0

Set PHP 7.0 Version in UbuntuSet PHP 7.Zero Model in Ubuntu
———— Set Default PHP Model 7.1 ————
$ sudo update-alternatives –set php /usr/bin/php7.1

Set PHP 7.1 Version in UbuntuSet PHP 7.1 Model in Ubuntu
———— Set Default PHP Model 8.0 ————
$ sudo update-alternatives –set php /usr/bin/php8.0

Set PHP 8 VersionSet PHP Eight Model

8. To set the PHP model that can work with the Apache internet server, use the instructions under. First, disable the present model with the a2dismod command after which allow the one you need with the a2enmod command.

———– Disable PHP Model ———–
$ sudo a2dismod php5.6
$ sudo a2dismod php7.0
$ sudo a2dismod php7.1
$ sudo a2dismod php7.2
$ sudo a2dismod php7.3
$ sudo a2dismod php7.4
$ sudo a2dismod php8.0

———– Allow PHP Model ———–
$ sudo a2enmod php5.6
$ sudo a2enmod php7.1
$ sudo a2enmod php7.2
$ sudo a2enmod php7.3
$ sudo a2enmod php7.4
$ sudo a2enmod php8.0

———– Restart Apache Server ———–
$ sudo systemctl restart apache2

Enable Disable PHP Modules for ApacheAllow Disable PHP Modules for Apache

9. After switching from one model to a different, yow will discover your PHP configuration file, by working the command under.

———— For PHP 5.6 ————
$ sudo update-alternatives –set php /usr/bin/php5.6
$ php -i | grep “Loaded Configuration File”

———— For PHP 7.0 ————
$ sudo update-alternatives –set php /usr/bin/php7.0
$ php -i | grep “Loaded Configuration File”

———— For PHP 7.1 ————
$ sudo update-alternatives –set php /usr/bin/php7.1
$ php -i | grep “Loaded Configuration File”

———— For PHP 7.2 ————
$ sudo update-alternatives –set php /usr/bin/php7.2
$ php -i | grep “Loaded Configuration File”

———— For PHP 7.3 ————
$ sudo update-alternatives –set php /usr/bin/php7.3
$ php -i | grep “Loaded Configuration File”

———— For PHP 7.4 ————
$ sudo update-alternatives –set php /usr/bin/php7.4
$ php -i | grep “Loaded Configuration File”

———— For PHP 8.0 ————
$ sudo update-alternatives –set php /usr/bin/php8.0
$ php -i | grep “Loaded Configuration File”

Find PHP Configuration FileDiscover PHP Configuration File

You may additionally like:

  1. How you can Use and Execute PHP Codes in Linux Command Line
  2. 12 Helpful PHP Commandline Utilization Each Linux Person Should Know
  3. How you can Conceal PHP Model in HTTP Header

On this article, we confirmed the right way to set up all of the supported variations of PHP in Ubuntu and its derivatives. In case you have any queries or ideas to share, achieve this through the suggestions kind under.

If You Respect What We Do Right here On TecMint, You Ought to Contemplate:

TecMint is the quickest rising and most trusted group website for any form of Linux Articles, Guides and Books on the net. Tens of millions of individuals go to TecMint! to look or browse the 1000’s of revealed articles obtainable FREELY to all.

In the event you like what you might be studying, please contemplate shopping for us a espresso ( or 2 ) as a token of appreciation.

Support Us

We’re grateful in your by no means ending assist.

Supply

Germany Devoted Server

Leave a Reply