{"id":27996,"date":"2018-09-06T02:36:25","date_gmt":"2018-09-06T07:36:25","guid":{"rendered":"https:\/\/www.rosehosting.com\/blog\/?p=27996"},"modified":"2022-12-12T07:12:22","modified_gmt":"2022-12-12T13:12:22","slug":"how-to-install-php-7-2-on-debian-9","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-php-7-2-on-debian-9\/","title":{"rendered":"How to Install PHP 7.2 on Debian 9"},"content":{"rendered":"
We will show you how to install PHP 7.2 on a Linux server running Debian 9 as an operating system. PHP is a server-side scripting language commonly used for Web development, but it is also used as a general-purpose programming language. PHP powers WordPress<\/a>, the most popular content management system used for blogging and building websites as well as may other e-commerce websites, customer relationship management software, enterprise resource planning software and much more.<\/p>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n PHP 7 offers much better performances than PHP 5.6 and older PHP versions. Compared with PHP 5.6, PHP 7.2 could execute as much as three times more requests. If you have installed WordPress on your Linux VPS<\/a>, this means much lower server load, thus you should expect your website to run faster with PHP 7.2.<\/p>\r\n\r\n\r\n\r\n In addition, PHP 7.2 offers some security improvements.<\/p>\r\n\r\n\r\n\r\n There are some deprecations <\/a>though that you may want to check before you consider upgrading to PHP 7.2.<\/p>\r\n\r\n\r\n\r\n Before you start with the installation of PHP 7.2 on your Debian VPS<\/a>, make sure that you have full root access to it. Connect to the server via SSH<\/a> and upgrade all the system software to the latest version available. You can do this by running the following commands in the terminal:<\/p>\r\n\r\n\r\n\r\n This will update the package index and will update the software currently installed on the server to the latest version.<\/p>\r\n\r\n\r\n\r\n Once your system is fully up to date, you can proceed to the next step, which is installing PHP 7.2.<\/p>\r\n\r\n\r\n\r\n Import the signing key and enable the PPA for PHP 7.2 by using the following commands:<\/p>\r\n\r\n\r\n\r\n Once you are done with this, run the package index update once again using the command below:<\/p>\r\n\r\n\r\n\r\n In case you get an error like the one below:<\/p>\r\n\r\n\r\n\r\n It means there are some missing packages that you need to install first. Install the required packages by running the following command:<\/p>\r\n\r\n\r\n\r\n Then, run the update command again.<\/p>\r\n\r\n\r\n\r\n Finally, install PHP 7.2 on your Debian 9 VPS<\/a> including some of the commonly used extensions using the command below:<\/p>\r\n\r\n\r\n\r\n To verify the installation is completed run the following command:<\/p>\r\n\r\n\r\n\r\n The output should be very similar to the one below:<\/p>\r\n\r\n\r\n\r\n The 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 It will return the path to the Edit the file using a text editor of your choice. We will use Once you change the settings, save and close the file. If you are using Apache<\/a> 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<\/a> and PHP-FPM, you should restart the PHP-FPM service.<\/p>\r\n\r\n\r\n\r\n You can also create a sample To create the file:<\/p>\r\n\r\n\r\n\r\n and paste the following:<\/p>\r\n\r\n\r\n\r\n Save and close the file, then open your favorite web browser and access the file by using your server IP address in the URL followed by the name of the file.<\/p>\r\n\r\n\r\n\r\n Our fully managed PHP Hosting<\/a> is already installed with the latest release of PHP 7.2, so you don’t have to install it by yourself. If you need any other PHP version to be installed on your server, just let our system administrators know via live chat or support ticket, and it will be taken care of it immediately. They are available 24\/7. For more updates, you can also check our guide on How to Install PHP 7.3 on Debian 9<\/a>.<\/p>\r\n\r\n\r\n\r\n PS. If you liked this post on how to install PHP 7.2 on Debian 9, please share it with your friends on the social networks or simply leave a reply below with your question or comment. Thanks.<\/p>\r\n","protected":false},"excerpt":{"rendered":" We will show you how to install PHP 7.2 on a Linux server running Debian 9 as an operating system. … <\/p>\nWhy do you want to install PHP 7.2 on your Debian 9 VPS?<\/h3>\r\n\r\n\r\n\r\n
Prerequisites<\/h3>\r\n\r\n\r\n\r\n
sudo apt-get update \r\nsudo apt-get upgrade<\/pre>\r\n\r\n\r\n\r\n
Install PHP 7.2 on Debian 9 VPS<\/h3>\r\n\r\n\r\n\r\n
wget -q https:\/\/packages.sury.org\/php\/apt.gpg -O- | sudo apt-key add -\r\necho \"deb https:\/\/packages.sury.org\/php\/ stretch main\" | sudo tee \/etc\/apt\/sources.list.d\/php.list<\/pre>\r\n\r\n\r\n\r\n
sudo apt-get update<\/pre>\r\n\r\n\r\n\r\n
Reading package lists... Done\r\nE: The method driver \/usr\/lib\/apt\/methods\/https could not be found.\r\nN: Is the package apt-transport-https installed?\r\nE: Failed to fetch https:\/\/packages.sury.org\/php\/dists\/stretch\/InRelease\r\nE: Some index files failed to download. They have been ignored, or old ones used instead.\r\n<\/pre>\r\n\r\n\r\n\r\n
sudo apt-get install ca-certificates apt-transport-https<\/pre>\r\n\r\n\r\n\r\n
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\r\n<\/pre>\r\n\r\n\r\n\r\n
php -v<\/pre>\r\n\r\n\r\n\r\n
# php -v\r\nPHP 7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35 (cli) (built: Sep 1 2018 08:11:34) ( NTS )\r\nCopyright (c) 1997-2018 The PHP Group\r\nZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies\r\n with Zend OPcache v7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35, Copyright (c) 1999-2018, by Zend Technologies\r\n<\/pre>\r\n\r\n\r\n\r\n
Change\/Customize PHP 7.2 settings on a Debian VPS<\/h3>\r\n\r\n\r\n\r\n
php.ini<\/code> file. To find the path to this file, you can use the command below:<\/p>\r\n\r\n\r\n\r\n
php --ini | grep \"Loaded Configuration File\"<\/pre>\r\n\r\n\r\n\r\n
php.ini<\/code> file which is currently loaded.<\/p>\r\n\r\n\r\n\r\n
# php --ini | grep \"Loaded Configuration File\"\r\nLoaded Configuration File: \/etc\/php\/7.2\/cli\/php.ini<\/pre>\r\n\r\n\r\n\r\n
nano<\/code> in this example.<\/p>\r\n\r\n\r\n\r\n
nano \/etc\/php\/7.2\/cli\/php.ini<\/pre>\r\n\r\n\r\n\r\n
info.php<\/code> and see if the PHP files and executed on the server.<\/p>\r\n\r\n\r\n\r\n
nano \/var\/www\/html\/info.php<\/pre>\r\n\r\n\r\n\r\n
<?php phpinfo(); ?>\r\n<\/pre>\r\n\r\n\r\n\r\n
http:\/\/IP-ADDRESS\/info.php\r\n\r\nWith the completion of this tutorial you have learned how to install PHP 7.2 on your Debian 9 based server. \r\nFor the installation guide of PHP 7.2 on Ubuntu 16.04 please follow this tutorial on how to install PHP 7.2 on Ubuntu 16.04<\/a>.<\/pre>\r\n\r\n\r\n\r\n
\r\n\r\n\r\n\r\n<\/figure><\/div>\r\n\r\n\r\n\r\n