Debian Linux 9 upgrade from php 7.0 to 7.2

7 posts / 0 new
Last post
#1 Sun, 09/09/2018 - 14:01
impact5641

Debian Linux 9 upgrade from php 7.0 to 7.2

Hello,

I tried upgrading PHP 7.0 to 7.2 on Debian with some issues. Can anybody point me in the correct direction on how to upgrade this correctly?

Sun, 09/09/2018 - 19:07
impact5641

Issue Fixed

Mon, 09/10/2018 - 02:55
Femi

Please may I know how this was resolved? I am about to upgrade from pho7.0.3 to 7.2 on ubuntu 16.4 - I would like to know possible challenges and how to address it

MartFame

Tue, 09/11/2018 - 03:10
fuerst

I had good results to install newer/older PHP versions in addition to the default one using phpbrew. You may switch between default and other PHP's in the Virtual Site settings at Server Configuration > PHP Versions.

This is an example how to install PHP 7.1 on Ubuntu 14.04. Should be working for PHP 7.2 too:

Only once - probably different on newer Ubuntu or Debian:

apt-get install build-essential bison autoconf automake libtool re2c flex autotools-dev \
  libxml2-dev libssl-dev libbz2-dev libdb5.1-dev libjpeg-dev libXpm-dev libfreetype6-dev \
  libt1-dev libgmp3-dev libldap2-dev libmcrypt-dev libmhash-dev freetds-dev zlib1g-dev \
  libmysqlclient-dev libncurses5-dev libpcre3-dev libsqlite0-dev libaspell-dev libreadline6-dev\
  librecode-dev libxslt1-dev icu-devtools libexpat1-dev libicu-dev libicu52 libjpeg-turbo8-dev \
  libjpeg8-dev libmcrypt4 libpng12-dev m4 zlib1g-dev pkg-config libcurl4-openssl-dev libc-client2007e-dev \
  libmagickwand-dev
ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

Everytime you install/upgrade:

phpbrew self-update
phpbrew update
rm /opt/phpbrew/distfiles/*
rm -rf /opt/phpbrew/build/*

phpbrew install -j 2 7.1 +bcmath +bz2 +calendar +cgi +ctype +exif +fileinfo +filter +dom +ftp +gd +hash +iconv +imap +intl +ipc +json +mbregex \
  +mbstring +mcrypt +mhash +mysql +openssl +pcntl +pdo +posix +readline +session +soap +sockets +sqlite +xml_all +zip +zlib -- \
  --with-config-file-path=/etc/php71/cgi --with-config-file-scan-dir=/etc/php71/cgi/conf.d --with-mysql-sock=/var/run/mysqld/mysqld.sock \
  --with-curl --with-gd --with-png-dir=/usr/lib/x86_64-linux-gnu --with-jpeg-dir=/usr/lib/x86_64-linux-gnu --with-freetype-dir=/usr/include/freetype2 \
  --enable-gd-native-ttf --with-xpm-dir=/usr/lib/x86_64-linux-gnu  --enable-opcache

rm -f /usr/local/bin/php71*

strip /opt/phpbrew/php/php-7.1.*/bin/php-cgi /opt/phpbrew/php/php-7.1.*/bin/php

# Replace "php-7.1.21" by the installed version.
VERSION="php-7.1.21"

ln /opt/phpbrew/php/${VERSION}/bin/php-cgi /usr/local/bin/php71-cgi
ln /opt/phpbrew/php/${VERSION}/bin/php /usr/local/bin/php71

mkdir -p /etc/php71/cgi /etc/php71/conf.d
cp /opt/phpbrew/php/${VERSION}/etc/php.ini /etc/php71/cgi/php.ini
ln -fs /etc/php71/conf.d /etc/php71/cgi/

# Path for "zend_extension" in php.ini's / conf.d/*.ini needs to be absolute.
# Adopt to your specific PHP version.
echo "zend_extension = /opt/phpbrew/php/php-7.1.21/lib/php/extensions/no-debug-non-zts-20160303/opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1" | tee /etc/php71/conf.d/opcache.ini

# Optional: Install PECL extensions
phpbrew use ${VERSION}

phpbrew ext install apcu
cp /opt/phpbrew/php/${VERSION}/var/db/apcu.ini /etc/php71/conf.d

phpbrew ext install imagick
cp /opt/phpbrew/php/${VERSION}/var/db/imagick.ini /etc/php71/conf.d/imagick.ini

# Only when upgrading - list older Versions...
phpbrew list
# ... and remove it:
phpbrew remove php-7.1.16

service  apache2 reload
Wed, 09/12/2018 - 11:32
jimdunn

I don't know what seems more scary... using non-approved repos on CENTOS or this phpbrew on UBUNTU...

In my production environments I like to use stock OS and stock repos and stock PHP, etc.

Thu, 09/13/2018 - 08:24
fuerst

I need to support different PHP versions at one machine so this is one way to do it. That way I did not run in any PHP-related problems since years.

Sun, 09/23/2018 - 14:13
Freddy63
Freddy63's picture

I wrote a tutorial for this last month, it was tested on Ubuntu 16.04. But should work on Debian 9 too. here it is, How to Use Multiple PHP Versions With Virtualmin and Nginx

Topic locked