How to install PHP 7.2 on Ubuntu and Debian

Php official logo

In general, Gnu / Linux servers use version 7 and 5.6 of PHP, but these versions are not the latest versions or the most functional, although they are the most stable and free of bugs. Future versions of this programming language are interesting and can be on a local server to be tested, experiment with our web applications or simply learn to program with this programming language.

For this reason we are going to tell you how to get the latest version of PHP and install it on Ubuntu or Debian or derived distributions that we can use as an operating system for a server. As we have said before, it is not recommended to use this version on production servers as it could cause serious problems or have security holes. But it is still useful to experiment.

To install PHP 7.2 in Ubuntu and Debian we have to make use of an external repository and install dependencies that are needed for installation and running this new version of PHP. To do this we open the terminal and write the following:

apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php

Then we write the following to install PHP 7.2:

apt-get update
sudo apt-get install php7.2

This will install the PHP 7.2 version but will not make the operating system use it by default. To do this, we have to write the following in the terminal:

update-alternatives --set php /usr/bin/php7.2

And if we use a LAMP server, we will have to make modifications in Apache so that it recognizes this version. For this we have to write the following in the terminal:

a2enmod php7.2
systemctl restart apache2

With this we will have installed version 7.2 of PHP, now we only need to install modules and add-ons that we need, but that is something that we leave you to your will and need. As you can see, the installation process is simple and fast, but we must remember that the version may bring some other problem and it is not recommended to use it on production equipment.

The content of the article adheres to our principles of editorial ethics. To report an error click here.

Be the first to comment

Leave a Comment

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



  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.