Recently I explained how to install PHP 7 in CentOS 7. Today, I will show how to install PHP 7.2 on Debian 9.

Linux server-oriented operating systems use not-so-current versions of the basic packages because they are the most tested. This situation has as main advantage that the packages that are in the official repositories are very stable; however, not having the latest versions of the packages means that new features are not always available.

Linux Security
Linux Security

With this in mind, it’s easy to assume that some essential applications can’t be used without updating some key packages like PHP. For example, the latest stable version of Laravel requires PHP 7.1.3 but Debian 9 brings in its repositories version 7.0.

In others words, there are times when it is necessary to update some essential packages. Today it’s PHP’s turn on Debian 9.

Why you need

The process is quite simple, however, you must execute commands as a superuser. To do this, you can use a user with sudo enabled or directly be root.

You also need to be somewhat familiar with the use of the terminal, as we will do everything through the command line interface.

With this in mind, you can get started to install PHP 7.2.

Let’s get to work

Now that you have decided to update PHP, the first thing is to update the system. With that, you will get the versions of the packages but only those related to security. Anyway, it’s a good idea to do it. Run:

Then, enter your password to become root. Now, run:

1.- Upgrading the system
1.- Upgrading the system

That’s enough.

So, you can check this by executing the following command:

2.- Showing the version of the PHP package that comes in the official repositories.
2.- Showing the version of the PHP package that comes in the official repositories.

As you can see, Debian 9 comes with PHP 7.0 by default.

The next step is to install some necessary packages such as: apt-transport-https lsb-release and ca-certificates.

3.- Installing some required packages
3.- Installing some required packages

To install PHP 7.2 you need an external repository. Run:

4.- Downloading GPG key
4.- Downloading GPG key

Next:

5.- Adding the external repository to install PHP 7.2
5.- Adding the external repository to install PHP 7.2

Then, proceed to update the repository cache.

6.- apt update command
6.- apt update command

Now, search the repository database for the PHP package and you’ll see that version 7.2 is available.

7.- Showing the new version of PHP on repository
7.- Showing the new version of PHP on the repository

And proceed to install the PHP 7.2 packages you want. I’ll install these for now.

8.- Installing PHP7.2 packages
8.- Installing PHP7.2 packages

Finally, you can check the installed version. To do this, run.

9.- Showing the PHP version installed.
9.- Showing the PHP version installed.

Conclusion

In the final analysis, it can be said that having old and tested packages has its advantages but from time to time it is convenient to update them. Especially if other applications make use of them like Laravel with PHP.

Installing PHP 7.2 in Debian 9 is simple and it is recommended to do it to have important security updates especially if the server works a lot with web applications.

We want to know about you, have you used PHP? is your favorite language? did you find the article interesting? let us know in the comments.

Please share this article.

 

Spread the love
  • 7
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here