Compile PHP 7.1, 7.2 and 7.3 besides 7.0

For Debian you can use binary packages. Just follow this article:

sudo apt update 
sudo apt upgrade
sudo apt install ca-certificates apt-transport-https 
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
sudo apt update
sudo apt install php5.6
sudo apt install php5.6-dev php5.6-cli php5.6-fpm php5.6-common php5.6-curl php5.6-mbstring php5.6-mysql php5.6-xml
sudo apt update
sudo apt install php7.3
sudo apt install php7.3-dev php7.3-cli php7.3-fpm php7.3-common php7.3-curl php7.3-mbstring php7.3-mysql php7.3-xml php7.3-soap php7.3-xml php7.3-gd php7.3-zip php7.3-mbstring php7.3-xml php7.3-dom php7.3-bcmath php7.3-bz2 php7.3-curl php7.3-gd php7.3-intl php7.3-json php7.3-mbstring php7.3-readline php7.3-xml php7.3-zip

If you don’t want to use binary packages and instead compile from source then follow below steps:

01
02
03
04
05
06
07
08
09
10
apt-get install build-essential nano
apt-get install libzip-dev libfcgi-dev libfcgi0ldbl libjpeg62-turbo-dev libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev libxml2-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev libkrb5-dev libpq-dev libxml2-dev libxslt1-dev
ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
cd /usr/include
ln -s x86_64-linux-gnu/curl
mkdir -p /opt/php-7.1
mkdir /usr/local/src/php7.1-build
cd /usr/local/src/php7.1-build
wget http://de2.php.net/get/php-7.1.25.tar.bz2/from/this/mirror -O php-7.1.25.tar.bz2
tar jxf php-7.1.25.tar.bz2

./configure –prefix=/opt/php-7.1 –with-pdo-pgsql –with-zlib-dir –with-freetype-dir –enable-mbstring –with-libxml-dir=/usr –enable-soap –enable-calendar –with-curl –with-mcrypt –with-zlib –with-gd –with-pgsql –disable-rpath –enable-inline-optimization –with-bz2 –with-zlib –enable-sockets –enable-sysvsem –enable-sysvshm –enable-pcntl –enable-mbregex –enable-exif –enable-bcmath –with-mhash –enable-zip –with-pcre-regex –with-pdo-mysql –with-mysqli –with-mysql-sock=/var/run/mysqld/mysqld.sock –with-jpeg-dir=/usr –with-png-dir=/usr –enable-gd-native-ttf –with-openssl –with-fpm-user=www-data –with-fpm-group=www-data –with-libdir=/lib/x86_64-linux-gnu –enable-ftp –with-imap –with-imap-ssl –with-kerberos –with-gettext –with-xmlrpc –with-xsl –enable-opcache –enable-fpm
make
make install

cp /usr/local/src/php7.1-build/php-7.1.25/php.ini-production /opt/php-7.1/lib/php.ini
cp /opt/php-7.1/etc/php-fpm.conf.default /opt/php-7.1/etc/php-fpm.conf
cp /opt/php-7.1/etc/php-fpm.d/www.conf.default /opt/php-7.1/etc/php-fpm.d/www.conf
vi /opt/php-7.1/etc/php-fpm.conf

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[...]
pid = run/php-fpm.pid
[...]
vi /opt/php-7.1/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8999
[...]
vi /lib/systemd/system/php-7.1-fpm.service
[Unit]
Description=The PHP 7.1 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/opt/php-7.1/var/run/php-fpm.pid
ExecStart=/opt/php-7.1/sbin/php-fpm --nodaemonize --fpm-config /opt/php-7.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
systemctl enable php-7.1-fpm.service
systemctl daemon-reload
systemctl start php-7.1-fpm.service
vi /opt/php-7.1/lib/php.ini
zend_extension=opcache.so
# test:
cd /opt/php-7.1/bin
./php --version
# ispconfig:
FastCGI Settings tab:
Path to the PHP FastCGI binary: /opt/php-7.1/bin/php-cgi
Path to the php.ini directory: /opt/php-7.1/lib
PHP-FPM Settings tab:
Path to the PHP-FPM init script: php-7.1-fpm
Path to the php.ini directory: /opt/php-7.1/lib
Path to the PHP-FPM pool directory: /opt/php-7.1/etc/php-fpm.d

Configure PHP 7.2

mkdir -p /opt/php-7.2

mkdir /usr/local/src/php7.2-build

cd /usr/local/src/php7.2-build
wget http://de2.php.net/get/php-7.2.13.tar.bz2/from/this/mirror -O php-7.2.13.tar.bz2
tar jxf php-7.2.13.tar.bz2
cd php-7.2.13

./configure –prefix=/opt/php-7.2 –with-pdo-pgsql –with-zlib-dir –with-freetype-dir –enable-mbstring –with-libxml-dir=/usr –enable-soap –enable-calendar –with-curl –with-zlib –with-gd –with-pgsql –disable-rpath –enable-inline-optimization –with-bz2 –with-zlib –enable-sockets –enable-sysvsem –enable-sysvshm –enable-pcntl –enable-mbregex –enable-exif –enable-bcmath –with-mhash –enable-zip –with-pcre-regex –with-pdo-mysql –with-mysqli –with-mysql-sock=/var/run/mysqld/mysqld.sock –with-jpeg-dir=/usr –with-png-dir=/usr –with-openssl –with-fpm-user=www-data –with-fpm-group=www-data –with-libdir=/lib/x86_64-linux-gnu –enable-ftp –with-imap –with-imap-ssl –with-kerberos –with-gettext –with-xmlrpc –with-xsl –enable-opcache –enable-fpm
make
make install

cp /usr/local/src/php7.2-build/php-7.2.13/php.ini-production /opt/php-7.2/lib/php.ini
cp /opt/php-7.2/etc/php-fpm.conf.default /opt/php-7.2/etc/php-fpm.conf
cp /opt/php-7.2/etc/php-fpm.d/www.conf.default /opt/php-7.2/etc/php-fpm.d/www.conf

vi /opt/php-7.2/etc/php-fpm.conf
[…]
pid = run/php-fpm.pid
[…]

vi /opt/php-7.2/etc/php-fpm.d/www.conf
[…]
listen
= 127.0.0.1:8998
[…]

vi /lib/systemd/system/php-7.2-fpm.service

[Unit]
Description=The PHP 7.2 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php-7.2/var/run/php-fpm.pid
ExecStart=/opt/php-7.2/sbin/php-fpm –nodaemonize –fpm-config /opt/php-7.2/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

systemctl enable php-7.2-fpm.service
systemctl daemon-reload
systemctl start php-7.2-fpm.service
vi /opt/php-7.2/lib/php.ini
[…]
zend_extension=opcache.so

# ispconfig:
FastCGI Settings tab:
Path to the PHP FastCGI binary: /opt/php-7.2/bin/php-cgi
Path to the php.ini directory: /opt/php-7.2/lib

PHP-FPM Settings tab:
Path to the PHP-FPM init script: php-7.2-fpm
Path to the php.ini directory: /opt/php-7.2/lib
Path to the PHP-FPM pool directory: /opt/php-7.2/etc/php-fpm.d

Configure PHP 7.3

mkdir -p /opt/php-7.3

mkdir /usr/local/src/php7.3-build

cd /usr/local/src/php7.3-build
wget http://de2.php.net/get/php-7.3.0.tar.bz2/from/this/mirror -O php-7.3.0.tar.bz2
tar jxf php-7.3.0.tar.bz2

cd php-7.3.0
apt-get install libzip-dev
./configure –prefix=/opt/php-7.3 –with-pdo-pgsql –with-zlib-dir –with-freetype-dir –enable-mbstring –with-libxml-dir=/usr –enable-soap –enable-calendar –with-curl –with-zlib –with-gd –with-pgsql –disable-rpath –enable-inline-optimization –with-bz2 –with-zlib –enable-sockets –enable-sysvsem –enable-sysvshm –enable-pcntl –enable-mbregex –enable-exif –enable-bcmath –with-mhash –enable-zip –with-pcre-regex –with-pdo-mysql –with-mysqli –with-mysql-sock=/var/run/mysqld/mysqld.sock –with-jpeg-dir=/usr –with-png-dir=/usr –with-openssl –with-fpm-user=www-data –with-fpm-group=www-data –with-libdir=/lib/x86_64-linux-gnu –enable-ftp –with-imap –with-imap-ssl –with-kerberos –with-gettext –with-xmlrpc –with-xsl –enable-opcache –enable-fpm
make
make install

cp /usr/local/src/php7.3-build/php-7.3.0/php.ini-production /opt/php-7.3/lib/php.ini
cp /opt/php-7.3/etc/php-fpm.conf.default /opt/php-7.3/etc/php-fpm.conf
cp /opt/php-7.3/etc/php-fpm.d/www.conf.default /opt/php-7.3/etc/php-fpm.d/www.conf

vi /opt/php-7.3/etc/php-fpm.conf
[…]
pid = run/php-fpm.pid
[…]

vi /opt/php-7.3/etc/php-fpm.d/www.conf
[…]
listen
= 127.0.0.1:8997
[…]

vi /lib/systemd/system/php-7.3-fpm.service

[Unit]
Description=The PHP 7.3 FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/opt/php-7.3/var/run/php-fpm.pid
ExecStart=/opt/php-7.3/sbin/php-fpm –nodaemonize –fpm-config /opt/php-7.3/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

systemctl enable php-7.3-fpm.service
systemctl daemon-reload
systemctl start php-7.3-fpm.service
vi /opt/php-7.3/lib/php.ini
[…]
zend_extension=opcache.so

# ispconfig:
FastCGI Settings tab:
Path to the PHP FastCGI binary: /opt/php-7.3/bin/php-cgi
Path to the php.ini directory: /opt/php-7.3/lib

PHP-FPM Settings tab:
Path to the PHP-FPM init script: php-7.3-fpm
Path to the php.ini directory: /opt/php-7.3/lib
Path to the PHP-FPM pool directory: /opt/php-7.3/etc/php-fpm.d

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp