Install PHP 7.2 on Debian 9 Rumi, December 8, 2019 Before you start with the installation of PHP 7.2 on your Debian VPS, make sure that you have full root access to it. Connect to the server via SSH and upgrade all the system software to the latest version available. You can do this by running the following commands in the terminal: sudo apt-get update sudo apt-get upgrade This will update the package index and will update the software currently installed on the server to the latest version. Once your system is fully up to date, you can proceed to the next step, which is installing PHP 7.2. Import the signing key and enable the PPA for PHP 7.2 by using the following commands: wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add - echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list Once you are done with this, run the package index update once again using the command below: sudo apt-get update In case you get an error like the one below: Reading package lists... Done E: The method driver /usr/lib/apt/methods/https could not be found. N: Is the package apt-transport-https installed? E: Failed to fetch https://packages.sury.org/php/dists/stretch/InRelease E: Some index files failed to download. They have been ignored, or old ones used instead. It means there are some missing packages that you need to install first. Install the required packages by running the following command: sudo apt-get install ca-certificates apt-transport-https The run the update command again. Finally, install PHP 7.2 on your Debian 9 VPS including some of the commonly used extensions using the command below: sudo apt-get install php7.2 php7.2-cli php7.2-common php7.2-opcache php7.2-curl php7.2-mbstring php7.2-mysql php7.2-zip php7.2-xml To verify the installation is completed run the following command: php -v The output should be very similar to the one below: # php -v PHP 7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35 (cli) (built: Sep 1 2018 08:11:34) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35, Copyright (c) 1999-2018, by Zend Technologies Change/Customize PHP 7.2 settings on a Debian VPS Next thing you may want to complete is to customize the PHP 7.2 settings to meet your requirements. You can do so by editing the php.ini file. To find the path to this file, you can use the command below: php --ini | grep "Loaded Configuration File" It will return the path to the php.ini file which is currently loaded. # php --ini | grep "Loaded Configuration File" Loaded Configuration File: /etc/php/7.2/cli/php.ini Edit the file using a text editor of your choice. We will use nano in this example. nano /etc/php/7.2/cli/php.ini Once you change the settings, save and close the file. If you are using Apache as a web server, you need to restart it for the new configuration to be loaded and for the changes to take effect. If you are using Nginx and PHP-FPM, you should restart the PHP-FPM service. You can also create a sample info.php and see if the PHP files and executed on the server. To create the file: nano /var/www/html/info.php and paste the following: <?php phpinfo(); ?> Save and close the file, then open you favorite web browser and access the file by using your server IP address in the URL followed by the name of the file. http://IP-ADDRESS/info.php Administrations Configurations (Linux) Debian 9PHP 7.2