How to install PHP 7.1.19 in optional mode on Debian 8 perfect server

botond published 2018/07/06, p - 20:45 time

Content

 

Introductory

Previously we prepared based on the Debian 8 ISPConfig-ancestor perfect server setup, which contains many useful programs and services that allow us to easily operate, configure, and maintain our shared web server. This server package - to maintain compatibility with older websites - a PHP It includes version 5.6, which already has newer and faster releases.

According to the PHP documentation, the 7.1 version is up to 2x faster than 5.6 and 14x faster than 5.0. Also, many new features have been added to the 7 branch and some of the things that were included in PHP 5.6 have been removed, so the 7 version is no longer compatible.

A PHP official site track, which branches to support and develop further:

  • Branch 5.6: Of which 5.6.36 is currently the most recent (April 2018, 26)
  • 7.0 Branch: 7.0.30 is the latest (2018 April 26.)
  • Branch 7.1: Of which 7.1.19 is the latest (June 2018.)
  • Branch 7.2: Of which 7.2.7 is the most recent (2018 June 21.)
  • Branch 7.3: Only alpha version available: 7.3.0 alpha 3 (2018 July 5.)

So it can be seen that currently (July 2018, 6) 5 branches are maintained by the PHP development team and these are being updated in parallel.

For the Debian 8 server environment, the 7.1 branch is right for us, because PHP 7.2 already has many Debian package requirements that Debian 8 does not meet if you want to compile from source, so you are already throwing it in the configure phase. the warnings. There are repositors that have binary install packages for PHP 7.2.x for Debian 8, however, these packages can only replace the default PHP system, so we will not deal with them here.

In this description, we will compile PHP from source and then install it on the server in optional mode, so it will be able to work with the default version 5.6, which means that web pages on the server can be set separately for this new version of PHP, which FastCGI and PHP-FPM modes will be available.

One another specification We install Debian 9 (Stretch) on a perfect server in a similar way to PHP 5.6.40.

 

 

Prerequisites

To prepare the description of the need for the previously prepared perfect server environment, This is now installed in 7.1.19's version of PHP.

 

If you have the required server environment, you can see it work.

 

Preparation

First, enter as root and update the APT Package Manager database and the packages themselves to be up to date. To do this, run the following two apt-get command:

apt-get update
apt-get upgrade

(It is recommended to do this before any major intervention so that we can always work with the latest packages.)

Let's remain root and create the necessary directories and download the PHP 7.1.19 source package at wget command:

mkdir /opt/php-7.1.19
mkdir /usr/local/src/php7-build
cd /usr/local/src/php7-build
wget http://uk3.php.net/get/php-7.1.19.tar.bz2/from/this/mirror -O php-7.1.19.tar.bz2
tar jxf php-7.1.19.tar.bz2
cd php-7.1.19/

So here we first created a working directory for the PHP system and created another for translation where we downloaded the PHP 7.1.19 source from the English mirror and then unpacked it.

Next, install the translation tools and the PHP development library packages:

apt-get install build-essential autoconf

apt-get install \
    libfcgi-dev \
    libfcgi0ldbl \
    libjpeg62-turbo-dbg \
    libmcrypt-dev \
    libssl-dev \
    libc-client2007e \
    libc-client2007e-dev \
    libxml2-dev \
    libbz2-dev \
    libcurl4-openssl-dev \
    libjpeg-dev \
    libpng12-dev \
    libfreetype6-dev \
    libkrb5-dev \
    libpq-dev \
    libxml2-dev \
    libxslt1-dev
For the sake of clarity, I put the longer commands here in several lines to see what packages are installed or what options are executed, etc. In this case, make sure that there is no character after the reverse slashes at the end of the lines.

 

If you want to compile PHP with IMAP support, you still need to create a link:

ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a

 

Translation

configuration

You can cut the source code configuration with the following long command (a / Usr / local / src / php7-build / php7.1.19 staying in library):

./configure \
    --prefix=/opt/php-7.1.19 \
    --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

For additional configuration switches, use the following command to refine your configuration if necessary:

./configure --help

The above configuration ran without errors, so now you can get the compilation.

Make

Compiling PHP is a bit longer, so I like to measure time, so team I command the make which will eventually print the run time. During this time, I will comfortably brew a good coffee. So the command is:

time make

It took 11 minutes for me to run VirtualBox running on an Intel I7-3770 host.

And now the installation is coming:

make install

If so, let's try our recent PHP installation:

/opt/php-7.1.19/bin/php --version

And the output, if all goes well:

PHP 7.1.19 (cli) (built: Jul  7 2018 00:12:44) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Post-translation settings

We will now put the .ini and .conf files in place, copying the factory files:

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

Open the /opt/php-7.1.19/etc/php-fpm.conf file

nano /opt/php-7.1.19/etc/php-fpm.conf

And remove the comment (;) from the following line:

[...]
pid = run/php-fpm.pid
[...]

Set the incoming port. Here you need to set an unused port number, which is the first free port from 9000 onwards. Since the server environment already has a default PHP 5.6 that uses port 9000, set 8999 here to /opt/php-7.1.19/etc/php-fpm.d/www.conf in file:

nano /opt/php-7.1.19/etc/php-fpm.d/www.conf
[...]
listen = 127.0.0.1:8999
[...]

If you are using more than one optional PHP, then move down this value, as appropriate, to set the first empty port for the newer PHP.

 

 

This description consists of several pages: