Upgrading Php 5.6 to 7.2 on Debian 8 Jessie

February 14, 2020

Here’s a great little script which will upgrade your PHP5.6 installation to PHP7.2.

Just copy and paste the code and run the shell script.

I found this script and updated it.

echo "Installing PHP 7.2 On Debian 8 Jessie and Debian 9 Stretch With Composer"
 echo "Created by volkansenturk"
 echo "Updated by IanArman"
 echo "http://bit.ly/2SuD528"

 sudo apt-get install apt-transport-https lsb-release ca-certificates -y
 sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
 echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

 sudo apt-get update

 sudo apt-get install php7.2 -y

 sudo apt-get install php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml -y

 sudo apt-get install git -y

 cd /tmp

 php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
 sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

 a2dismod php5
 service apache2 restart
 a2enmod php7.2
 service apache2 restart
 php -v