How to install PHP 7.2 on Ubuntu 16.04

The following article will show you how to install PHP 7.2 on Ubuntu 16.04. The first thing we are going to do is to update our Ubuntu by using the following command

sudo apt-get update

You will be asked for your password if you are not logged in as the root user.

You can also upgrade your Ubuntu server by typing the following:

sudo apt-get upgrade

Now that we have updated and upgraded Ubuntu, we will now proceed with installing PHP repository. We will use the repository by Ondrej Sury. First and foremost we will install the following packages so that we can proceed to add our repository. Type the following command on your terminal:

sudo apt-get install python-software-properties

We will now add the PHP Repository from Ondrej by typing the following:

sudo add-apt-repository ppa:ondrej/php

Now you can update your package list by typing the following:

sudo apt-get update

Now we can proceed with installing PHP 7.2 by typing the following command in your terminal:

sudo apt-get install php

The command will install PHP 7.2 in addition to other packages such as

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

You can verify if PHP is installed by typing the following command:

php –v

Depending on how and what you’re going to use, you may need additional PHP modules and packages. You may need some add some additional packages and PHP modules in order for PHP to work with your applications. You can install the most commonly needed modules with:

apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml

Now we have installed PHP 7.2 in your Ubuntu Server. If you were upgrading PHP from 5.6 to 7.2 you can disable the current PHP and enable PHP 7.2 in your server.

 

Leave a Reply

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

Translate »