Home » How to Install PHP 7.2 on Ubuntu 16.04, 18.04…

How to Install PHP 7.2 on Ubuntu 16.04, 18.04…

How to Install PHP 7.2 on Ubuntu 16.04, 18.04…

How to Install PHP 7.2 on Ubuntu 16.04, 18.04…

PHP 7.2 is the latest stable version of PHP and has many new features, improvements, and bug fixes. You should definitely use it if you want a better, faster website/application.

 

Update Ubuntu

sudo apt-get update && apt-get upgrade

Add the PHP repository

You can use a third-party repository to install the latest version of PHP. We’ll use the repository by Ondřej Surý.

First, make sure you have the following package installed so you can add repositories:

sudo apt-get install python-software-properties

Next, add the PHP repository from Ondřej:

sudo add-apt-repository ppa:ondrej/php

And finally, update your package list:

sudo apt-get update

 

Install PHP 7.2

After you’ve added the repository, you can install PHP 7.2 with the following command:

sudo apt-get install php7.2

This command will install additional packages:

  • libapache2-mod-php7.2
  • libargon2-0
  • libsodium23
  • libssl1.1
  • php7.2-cli
  • php7.2-common
  • php7.2-json
  • php7.2-opcache
  • php7.2-readline

And that’s it. To check if PHP 7.2 is installed on your server, run the following command:

php -v

php-v

Leave a Reply