How to install PHP 7.2 on Ubuntu and Debian

 

Installing PHP 7.2 on Ubuntu and Debian is a straightforward process. In this article, we will go through the steps required to install and configure PHP 7.2 on both Ubuntu and Debian systems.

Before we begin, it’s important to note that you should have administrative access to the system in order to install PHP.

First, we will update the package lists on the system to ensure that we have access to the latest versions of the software.

On Ubuntu:

sudo apt-get update

 

On Debian:

sudo apt-get update

 

Next, we will install the PHP 7.2 package along with some commonly used PHP extensions. On Ubuntu:

sudo apt-get install php7.2 php7.2-common php7.2-cli php7.2-fpm php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring

 

On Debian:

sudo apt-get install php7.2 php7.2-common php7.2-cli php7.2-fpm php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring

 

After the installation process is completed, you can check the version of PHP that is installed by running the following command:

 

This will give you the version of PHP that is currently installed on your system.

To ensure that PHP is working correctly on your system, you can create a simple PHP script with the following content:

<?php
echo "Hello, PHP!";
?>

Save the file with a .php extension and run it using a web server, such as Apache or Nginx.

Finally, you’ll want to check your php.ini configuration file to make sure everything is setup correctly. This can be found at /etc/php/7.2/fpm/php.ini or /etc/php/7.2/cli/php.ini depending on your setup.

That’s it! You now have PHP 7.2 installed and configured on your Ubuntu or Debian system. You can now start building PHP-based applications or websites.

Please signup/login to view answer.