How to Install PHP 7.2 on Debian 10
Table of Contents
Install PHP 7.2 on Debian 10
PHP has different versions 5.6, 7.0, 7.1 and 7.2. Currently, PHP 7.2 is the latest version of it. PHP 7.2 offers much better performance and faster request processing and some security updates. Debian 10 ships with PHP 7.0 which will no longer receive security updates so you should migrate from PHP 7.0 to PHP 7.2. In this tutorial, you will learn to install PHP 7.2 on Debian 10.
Before you start to install PHP on Debian 10. You must have the non-root user account on your server with sudo privileges
1. Installing PHP on Debian
To install PHP 7.2 on Debian 10, First, you will need to install some missing packages so you can add a new repository over HTTPS. Then you will add GPG keys after you will install PHP.
Update the package manager index by typing following in the terminal
sudo apt update
Now add missing package so you can add a new repository over HTTPS.
sudo apt install ca-certificates apt-transport-https
An import signing key and enable PPA for PHP 7.2 by using the following command.
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo apt-key add - sudo add-apt-repository "deb https://packages.sury.org/php/ $(lsb_release -cs) main"
Now update the package manager index again and install PHP 7.2 in Debian.
sudo apt update sudo apt install php7.2
Confirm the installation and check the version of PHP by typing:
2. Setup PHP for Nginx
Nginx by default does not support native PHP processing. You will need to install “fastCGI process manager”. Run the following command to install php-fpm on your server.
sudo apt install php-fpm
You can check the status where it is correctly installed or not by the following command
systemctl status php7.2-fpm
After installing the php-fpm package you will need to restart the Nginx server. To restart Nginx server run following command
sudo systemctl restart nginx
you can check PHP version by running following command
3. Installing PHP With Apache
If you are running Apache at backend then you need to install PHP and Apache PHP module on the server. To install PHP 7.2 and apache module type following command and press enter.
sudo apt install php libapache2-mod-php
After installing the PHP and apache-php module you will need to restart the Apache server by typing the following command.
sudo systemctl restart apache2
4. Install PHP Extensions
You will need to install some basic PHP extensions to run WordPress, Laravel like frameworks on the server. To install any of the PHP extensions on the server following is the basic format
sudo apt install php-[name_of_the_extension]
You can install a curl extension for PHP by running the following command.
sudo apt install php-curl
The following are some basic PHP extensions that need to be installed on your server.
sudo apt install php7.2-curl php7.2-mysql php7.2-common php7.2-cli php7.2-gd php7.2-opcache php7.2-mcrypt
To install more extensions you can use the above format.
5. Testing PHP processing
To test PHP is configured on your server properly or not you should create a file test.php inside directory /var/www/html/ with following code.
If you see the following output at https://YOUR_DOMAIN_NAME/test.php then you have installed PHP successfully.
You have installed PHP 7.2 on Debian 10 successfully with some of its basic extensions and tested successfully. If you have any of the queries regarding this then don’t forget to comment below.
How to Install Gradle on Linux Mint 19
How to Safely Remove Files and Directories Using Linux Command Line
How to List Users in Linux
How to Install PyCharm on CentOS 7
How to Set Up Cron Job on Debian 10
How to Install PhpStorm on Ubuntu 18.04
How to Search and Replace Text in Vim or Vi
How to Turn On Syntax Highlighting in Vim/Vi Editor
Concatenate Strings in Bash Script
How to Install Ruby on Ubuntu 18.04
How to Install RubyMine on Fedora 29
How to Install Kodi on Manjaro 18