How to Install PHP 7.1.19 in Optional Mode on Debian 8 Perfect Server (page 2)

botond published 2018/07/07, Sat - 01:50 time

Content

 

Create a Systemd unit file

Create the systemd unit file:

nano /lib/systemd/system/php-7.1.19-fpm.service

And let's put the following content and save it:

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

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

[Install]
WantedBy=multi-user.target

Then enable the service and reload the systemd-t:

systemctl enable php-7.1.19-fpm.service
systemctl daemon-reload

And let's start PHP-FPM:

systemctl start php-7.1.19-fpm.service

PHP-FPM can be easily verified by the following command:

ps -axf | grep fpm
29126 pts/0    S+     0:00  |                       \_ grep fpm
  979 ?        Ss     0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)
  982 ?        S      0:00  \_ php-fpm: pool www
  983 ?        S      0:00  \_ php-fpm: pool www
28978 ?        Ss     0:00 php-fpm: master process (/opt/php-7.1.19/etc/php-fpm.conf)
28979 ?        S      0:00  \_ php-fpm: pool www
28980 ?        S      0:00  \_ php-fpm: pool www

The output of the command shows nicely that the basic PHP5-FPM is running and the www pool of PHP-FPM 7 has started next to it.

 

 

Enable Zend OPcache

Edit the /opt/php-7.1.19/lib/php.ini file:

nano /opt/php-7.1.19/lib/php.ini

And add the following line to the very end:

zend_extension=opcache.so

We test:

/opt/php-7.1.19/bin/php --version
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
    with Zend OPcache v7.1.19, Copyright (c) 1999-2018, by Zend Technologies

 

Enable Memcache (Optional)

Install the following packages below apt-get command:

apt-get install libmemcached-dev pkg-config

Create the directory and download the wget command to extract the memcache plugin from Github, and unzip the directory:

mkdir /usr/local/src/php7-build/php-memcache
cd /usr/local/src/php7-build/php-memcache
wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip
unzip php7.zip
cd /usr/local/src/php7-build/php-memcache/php-memcached-php7

 

Prepare the source for the new (7.1.19) PHP phpize command:

/opt/php-7.1.19/bin/phpize

Correct output:

Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303

Configuration and translation:

./configure --with-php-config=/opt/php-7.1.19/bin/php-config
make
make install

To enable the memcache extension, edit the php.ini file again:

nano /opt/php-7.1.19/lib/php.ini

And add the following line to the end:

extension=memcached.so

 

Enable PHP 7.1.19 in ISPConfig

Let's step in ISPConfigba, then let's go to System -> Additional PHP Versions menu.

Installing PHP 7.1.19 - ISPConfig - Optional PHP versions

Here, click the Add new PHP version button, then fill in the fields on the first tab (Name) as follows:

Installing PHP 7.1.19 - ISPConfig - Optional PHP Version - Name

  • Server: From here, select your server from the drop-down list
  • Client: Leave this blank so all PHP clients will have access to this version of PHP
  • PHP Name: Here, you should enter the exact version here, so if you install more versions later, there will be no confusion.

Then click on FastCGI settings tab:

Installing PHP 7.1.19 - ISPConfig - Optional PHP Version - FastCGI Configuration

  • Path to the PHP FastCGI binary: / Opt / php-7.1.19 / bin / php-cgi
  • Path to the php.ini directory: / opt / php-7.1.19 / lib

Go to the PHP-FPM Options tab:

Installing PHP 7.1.19 - ISPConfig - Optional PHP Version - PHP-FPM Configuration

  • Path to the PHP-FPM init script: php-fpm-7.1.19
    (Note here that it does not start with / since we did not create an init.d startup file but a systemd unit file)
  • Path to the php.ini directory: / opt / php-7.1.19 / lib
  • Path to the PHP-FPM Pool directory: /opt/php-7.1.19/etc/php-fpm.d

Finally, save it.

 

Rotate Log Files (Optional)

You should consider rotating the log files with Logrotate. If we want to set it up, in this description we can find a way.

 

Conclusion

So we have created a new optional PHP version that can be enabled separately for any web page in the web page settings. This allows web pages to run independently with different versions of PHP.

 

 

This description consists of several pages: