{"id":2849,"date":"2018-02-08T17:51:14","date_gmt":"2018-02-08T14:51:14","guid":{"rendered":"https:\/\/www.howtoforge.com\/tutorial\/how-to-install-php-7-on-debian\/"},"modified":"2018-02-08T17:51:14","modified_gmt":"2018-02-08T14:51:14","slug":"how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9\/","title":{"rendered":"How to install PHP 7.1, 7.2 and 5.6 as PHP-FPM &#038; FastCGI for ISPConfig 3 on Debian 9"},"content":{"rendered":"<p>Debian 9 ships with PHP 7.0 as default PHP version. Major PHP versions are not 100% compatible with each other, so a website might require a newer or older PHP version to work. ISPConfig supports it to use multiple PHP versions on the same server, the PHP version can be selected for each website individually in the website settings. This tutorial shows how to install PHP 7.1, 7.2, and 5.6 as FPM and FCGI mode alongside PHP 7.0 on a Debian 9 server. The additional PHP versions are installed in the \/opt folder, so their installation does nit affect the default PHP version<\/p>\n<h2 id=\"-preliminary-note\">1 Preliminary Note<\/h2>\n<p>I will install PHP 7.1, 7.2 and 5.6. Please note that PHP-FPM can be used on both Apache and Nginx servers\u00a0while FastCGI is available only for Apache servers.<\/p>\n<h2 id=\"-install-the-prerequisites\">2 Install the prerequisites<\/h2>\n<p>Install the prerequisites for building PHP and the nano editor that I will use to edit the config files:<\/p>\n<p class=\"command\">apt-get install build-essential nano<\/p>\n<p class=\"command\">apt-get install libfcgi-dev libfcgi0ldbl\u00a0libjpeg62-turbo-dev libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev\u00a0libxml2-dev\u00a0libbz2-dev\u00a0libcurl4-openssl-dev\u00a0libjpeg-dev\u00a0libpng-dev\u00a0libfreetype6-dev\u00a0libkrb5-dev\u00a0libpq-dev libxml2-dev\u00a0libxslt1-dev<\/p>\n<p class=\"command\">ln -s \/usr\/lib\/libc-client.a \/usr\/lib\/x86_64-linux-gnu\/libc-client.a<\/p>\n<p class=\"command\">cd \/usr\/include<br \/>ln -s x86_64-linux-gnu\/curl<\/p>\n<p>(The last command is needed if you build PHP with <span class=\"system\">&#8211;with-imap<\/span>, because otherwise <span class=\"system\">.\/configure<\/span> will stop with the following error:<\/p>\n<p class=\"system\">checking for crypt in -lcrypt&#8230; yes<br \/>configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.<br \/><a href=\"https:\/\/www.howtoforge.com\/cdn-cgi\/l\/email-protection\" class=\"__cf_email__\" data-cfemail=\"ed9f828299ad9e889f9b889fdc\" target=\"_blank\" rel=\"noopener\">[email\u00a0protected]<\/a>:\/usr\/local\/src\/php5-build\/php-7.1.14#<\/p>\n<p>)<\/p>\n<h2 id=\"nbspcompilenbspphp-nbspas-phpfpm-and-fastcgi\">3\u00a0Compile\u00a0PHP 7.1\u00a0as PHP-FPM and Fastcgi<\/h2>\n<p>Download and extract PHP archive:<\/p>\n<p class=\"command\">mkdir -p \/opt\/php-7.1<br \/>mkdir \/usr\/local\/src\/php7.1-build<br \/>cd \/usr\/local\/src\/php7.1-build<br \/>wget http:\/\/de2.php.net\/get\/php-7.1.14.tar.bz2\/from\/this\/mirror\u00a0-O php-7.1.14.tar.bz2<br \/>tar jxf php-7.1.14.tar.bz2<\/p>\n<p class=\"command\">cd\u00a0php-7.1.14\/<\/p>\n<p>Configure and build PHP 7.1 as follows (you can adjust the <span class=\"system\">.\/configure<\/span> command to your needs, take a look at<\/p>\n<p class=\"command\">.\/configure &#8211;help<\/p>\n<p>to see all available options; if you use a different <span class=\"system\">.\/configure<\/span> command, it is possible that additional libraries are required, or the build process will fail):<\/p>\n<p class=\"command\">.\/configure &#8211;prefix=\/opt\/php-7.1 &#8211;with-pdo-pgsql &#8211;with-zlib-dir &#8211;with-freetype-dir &#8211;enable-mbstring &#8211;with-libxml-dir=\/usr &#8211;enable-soap &#8211;enable-calendar &#8211;with-curl &#8211;with-mcrypt &#8211;with-zlib &#8211;with-gd &#8211;with-pgsql &#8211;disable-rpath &#8211;enable-inline-optimization &#8211;with-bz2 &#8211;with-zlib &#8211;enable-sockets &#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-pcntl &#8211;enable-mbregex &#8211;enable-exif &#8211;enable-bcmath &#8211;with-mhash &#8211;enable-zip &#8211;with-pcre-regex &#8211;with-pdo-mysql &#8211;with-mysqli &#8211;with-mysql-sock=\/var\/run\/mysqld\/mysqld.sock\u00a0&#8211;with-jpeg-dir=\/usr &#8211;with-png-dir=\/usr &#8211;enable-gd-native-ttf &#8211;with-openssl &#8211;with-fpm-user=www-data &#8211;with-fpm-group=www-data &#8211;with-libdir=\/lib\/x86_64-linux-gnu &#8211;enable-ftp &#8211;with-imap &#8211;with-imap-ssl &#8211;with-kerberos &#8211;with-gettext &#8211;with-xmlrpc &#8211;with-xsl &#8211;enable-opcache &#8211;enable-fpm<\/p>\n<p>The last switch (<span class=\"system\">&#8211;enable-fpm<\/span>) makes sure this PHP version will work with PHP-FPM.<\/p>\n<p class=\"command\">make<br \/>make install<\/p>\n<p>Copy <span class=\"system\">php.ini<\/span> and <span class=\"system\">php-fpm.conf<\/span> to the correct locations:<\/p>\n<p class=\"command\">cp \/usr\/local\/src\/php7.1-build\/<span>php-7.1<\/span>\/php.ini-production \/opt\/php-7.1\/lib\/php.ini<\/p>\n<p class=\"command\">cp \/opt\/php-7.1\/etc\/php-fpm.conf.default \/opt\/php-7.1\/etc\/php-fpm.conf<br \/>cp\u00a0\/opt\/php-7.1\/etc\/php-fpm.d\/www.conf.default\u00a0\/opt\/php-7.1\/etc\/php-fpm.d\/www.conf<\/p>\n<p>Open <span class=\"system\">\/opt\/php-7.1\/etc\/php-fpm.conf<\/span> and adjust the following setting (remove the ; in front of the pid line):<\/p>\n<p class=\"command\">nano \/opt\/php-7.1\/etc\/php-fpm.conf<\/p>\n<pre>[...]&#13;\npid = run\/php-fpm.pid&#13;\n[...]<\/pre>\n<p><span>Then open \/opt\/php-7.1\/etc\/php-fpm.d\/www.conf<\/span><span>\u00a0and adjust the <\/span><span class=\"system\">listen<\/span><span> line, you must use an unused port (e.g. <\/span><span class=\"system\">8999<\/span><span>; port <\/span><span class=\"system\">9000<\/span><span> might be in use by Debian&#8217;s default PHP-FPM already):<\/span><\/p>\n<p class=\"command\">nano\u00a0\/opt\/php-7.1\/etc\/php-fpm.d\/www.conf<\/p>\n<pre>[...]&#13;\nlisten = 127.0.0.1:8999&#13;\n[...]<\/pre>\n<h3 id=\"-create-the-systemd-unit-file\">3.1 Create the systemd unit file<\/h3>\n<p>Next, we&#8217;ll create the system unit file which is used to start and stop the PHP-FPM daemon.<\/p>\n<p class=\"command\">nano\u00a0\/lib\/systemd\/system\/php-7.1-fpm.service<\/p>\n<p>with the following content:<\/p>\n<pre readability=\"8\">[Unit]<br\/>Description=The PHP 7.1 FastCGI Process Manager<br\/>After=network.target[Service]<br\/>Type=simple<br\/>PIDFile=\/opt\/php-7.1\/var\/run\/php-fpm.pid<br\/>ExecStart=\/opt\/php-7.1\/sbin\/php-fpm --nodaemonize --fpm-config \/opt\/php-7.1\/etc\/php-fpm.conf<br\/>ExecReload=\/bin\/kill -USR2 $MAINPID<\/p>[Install]<br\/>WantedBy=multi-user.target<\/p><\/pre>\n<p>Enable the service and reload systemd:<\/p>\n<p class=\"command\"><span>systemctl enable php-7.1-fpm.service<\/span><br \/>systemctl daemon-reload<\/p>\n<p>Finally, start PHP-FPM.<\/p>\n<p class=\"command\">systemctl start php-7.1-fpm.service<\/p>\n<p>To enable the Zend OPcache, open <span class=\"system\">\/opt\/php-7.1\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-7.1\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nzend_extension=opcache.so<\/pre>\n<h3 id=\"-enable-memcache-optional\">3.2 Enable Memcache (optional)<\/h3>\n<p>In this chapter, I will compile and enable the PHP Memcached extension.<\/p>\n<p>The first step is to install the\u00a0<span>libmemcached-dev package from Debian.<\/span><\/p>\n<p class=\"command\">apt-get install libmemcached-dev<\/p>\n<p>Then create a diretory, download the PHP memcache extension from Github, unpack the archive and enter the directory that contains the unpacked files.<\/p>\n<p class=\"command\">mkdir \/usr\/local\/src\/php7.1-build\/php-memcache<br \/>cd \/usr\/local\/src\/php7.1-build\/php-memcache<br \/>wget https:\/\/github.com\/php-memcached-dev\/php-memcached\/archive\/php7.zip<br \/>unzip php7.zip<br \/>cd php-memcached-php7<\/p>\n<p>Prepare he sources by running the phpize command from PHP 7.1.<\/p>\n<p class=\"command\">\/opt\/php-7.1\/bin\/phpize<\/p>\n<p>Configure and build the PHP memcache extension.<\/p>\n<p class=\"command\">.\/configure &#8211;with-php-config=\/opt\/php-7.1\/bin\/php-config<br \/>make<br \/>make install<\/p>\n<p>To enable the Memcache extension, open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-7.1\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-7.1\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nextension=memcached.so<\/pre>\n<h3 id=\"-install-xdebug-extension-optional\">3.3 Install xDebug extension (optional)<\/h3>\n<p>The<span>\u00a0<\/span><a href=\"https:\/\/xdebug.org\/docs\/install\" target=\"_blank\" rel=\"noopener\">xDebug<\/a>\u00a0module is a debugging extension for PHP. The installation is optional.<\/p>\n<p>Install xDebug with these commands.<\/p>\n<p class=\"command\">cd \/opt\/php-7.1\/etc<br \/>pecl -C .\/pear.conf update-channels<br \/>pecl -C .\/pear.conf install xdebug<\/p>\n<p>Then edit the php.ini file with an editor:<\/p>\n<p class=\"command\">nano \/opt\/php-7.1\/lib\/php.ini<\/p>\n<p>and add the following line at the end of the file:<\/p>\n<pre>zend_extension=\/opt\/php-7.1\/lib\/php\/extensions\/no-debug-non-zts-20160303\/xdebug.so<\/pre>\n<p>Finally restart the php-fpm daemon:<\/p>\n<p class=\"command\"><span>systemctl start\u00a0<\/span>php<span>-7.1-fpm.service<\/span><\/p>\n<p>Test the PHP version:<\/p>\n<p class=\"command\">cd\u00a0\/opt\/php-7.1\/bin<br \/>.\/php &#8211;version<\/p>\n<p>The output should be similar to this screenshot.<\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.1-debian_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.1-debian_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9.png\" alt=\"PHP 7.1 installed on Debian 9\" width=\"550\" height=\"58\" title=\"\"><\/a><\/p>\n<p><strong>Please note:<\/strong> The screenshot is from PHP 7.1.14,\u00a0the tutorial gets updated continuously for new PHP versions but we don&#8217;t take new screenshots each time, so the PHP version that you will see on your server might be newer. The current version of this tutorial is for\u00a0<span>php-7.1.14.<\/span><\/p>\n<h3 id=\"-enable-php-in-ispconfig\">3.4 Enable PHP 7.1 in ISPConfig<\/h3>\n<p>In ISPConfig 3.1, you can configure the new PHP version under <span class=\"system\">System &gt; Additional PHP Versions<\/span>. On the <span class=\"system\">Name<\/span> tab, you just fill in a name for the PHP version (e.g. <span class=\"system\">PHP 7.1<\/span>) &#8211; this PHP version will be listed under this name in the website settings in ISPConfig:<\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.1-name_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.1-name_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-1.png\" alt=\"PHP 7.1\" width=\"550\" height=\"245\" title=\"\"><\/a><\/p>\n<p><span>Go to the <\/span><span class=\"system\">FastCGI Settings<\/span><span> tab <\/span><span>and fill out the fields as follows:<\/span><\/p>\n<p class=\"system\"><span><strong>Path to the PHP FastCGI binary:<\/strong>\u00a0\/opt\/php-7.1\/bin\/php-cgi<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-7.1\/lib<\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.1-fcgi_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.1-fcgi_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-2.png\" alt=\"PHP 7.1 FCGI\" width=\"550\" height=\"224\" title=\"\"><\/a><\/p>\n<p>Then g\u00a0to the <span class=\"system\">PHP-FPM Settings<\/span> tab\u00a0and fill out the fields as follows:<\/p>\n<p class=\"system\"><span><strong>Path to the PHP-FPM init script:<\/strong>\u00a0php-7.1-fpm<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-7.1\/lib<br \/><strong>Path to the PHP-FPM pool directory:<\/strong>\u00a0\/opt\/php-7.1\/etc\/php-fpm.d<br \/><\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.1-fpm_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.1-fpm_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-3.png\" alt=\"PHP 7.1 FPM\" width=\"550\" height=\"267\" title=\"\"><\/a><\/p>\n<h2 id=\"nbspcompilenbspphp-nbspas-phpfpm-and-fastcgi-2\">4\u00a0Compile\u00a0PHP 7.2\u00a0as PHP-FPM and Fastcgi<\/h2>\n<p>Download and extract PHP from php.net and unpack the tar.bz2 file:<\/p>\n<p class=\"command\">mkdir -p \/opt\/php-7.2<br \/>mkdir \/usr\/local\/src\/php7.2-build<br \/>cd \/usr\/local\/src\/php7.2-build<br \/>wget http:\/\/de2.php.net\/get\/php-7.2.2.tar.bz2\/from\/this\/mirror\u00a0-O php-7.2.2.tar.bz2<br \/>tar jxf php-7.2.2.tar.bz2<\/p>\n<p class=\"command\">cd\u00a0php-7.2.2\/<\/p>\n<p>Configure and build PHP 7.2 as follows (you can adjust the<span>\u00a0<\/span><span class=\"system\">.\/configure<\/span><span>\u00a0<\/span>command to your needs, take a look at<\/p>\n<p class=\"command\">.\/configure &#8211;help<\/p>\n<p>to see all available options; if you use a different<span>\u00a0<\/span><span class=\"system\">.\/configure<\/span><span>\u00a0<\/span>command, it is possible that additional libraries are required, or the build process will fail):<\/p>\n<p class=\"command\">.\/configure &#8211;prefix=\/opt\/php-7.2 &#8211;with-pdo-pgsql &#8211;with-zlib-dir &#8211;with-freetype-dir &#8211;enable-mbstring &#8211;with-libxml-dir=\/usr &#8211;enable-soap &#8211;enable-calendar &#8211;with-curl &#8211;with-zlib &#8211;with-gd &#8211;with-pgsql &#8211;disable-rpath &#8211;enable-inline-optimization &#8211;with-bz2 &#8211;with-zlib &#8211;enable-sockets &#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-pcntl &#8211;enable-mbregex &#8211;enable-exif &#8211;enable-bcmath &#8211;with-mhash &#8211;enable-zip &#8211;with-pcre-regex &#8211;with-pdo-mysql &#8211;with-mysqli &#8211;with-mysql-sock=\/var\/run\/mysqld\/mysqld.sock\u00a0&#8211;with-jpeg-dir=\/usr &#8211;with-png-dir=\/usr &#8211;with-openssl &#8211;with-fpm-user=www-data &#8211;with-fpm-group=www-data &#8211;with-libdir=\/lib\/x86_64-linux-gnu &#8211;enable-ftp &#8211;with-imap &#8211;with-imap-ssl &#8211;with-kerberos &#8211;with-gettext &#8211;with-xmlrpc &#8211;with-xsl &#8211;enable-opcache &#8211;enable-fpm<\/p>\n<p>The last switch (<span class=\"system\">&#8211;enable-fpm<\/span>) makes sure this PHP version will work with PHP-FPM.<\/p>\n<p class=\"command\">make<br \/>make install<\/p>\n<p>Copy<span>\u00a0<\/span><span class=\"system\">php.ini<\/span><span>\u00a0<\/span>and<span>\u00a0<\/span><span class=\"system\">php-fpm.conf<\/span><span>\u00a0<\/span>to the correct locations:<\/p>\n<p class=\"command\">cp \/usr\/local\/src\/php7.2-build\/<span>php-7.2.2<\/span>\/php.ini-production \/opt\/php-7.2\/lib\/php.ini<\/p>\n<p class=\"command\">cp \/opt\/php-7.2\/etc\/php-fpm.conf.default \/opt\/php-7.2\/etc\/php-fpm.conf<br \/>cp\u00a0\/opt\/php-7.2\/etc\/php-fpm.d\/www.conf.default\u00a0\/opt\/php-7.2\/etc\/php-fpm.d\/www.conf<\/p>\n<p>Open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-7.2\/etc\/php-fpm.conf<\/span><span>\u00a0<\/span>and adjust the following setting (remove the ; in front of the pid line):<\/p>\n<p class=\"command\">nano \/opt\/php-7.2\/etc\/php-fpm.conf<\/p>\n<pre>[...]&#13;\npid = run\/php-fpm.pid&#13;\n[...]<\/pre>\n<p><span>Then open \/opt\/php-7.2\/etc\/php-fpm.d\/www.conf<\/span><span>\u00a0and adjust the<span>\u00a0<\/span><\/span><span class=\"system\">listen<\/span><span><span>\u00a0<\/span>line, you must use an unused port (e.g.<span>\u00a0<\/span><\/span><span class=\"system\">8998<\/span><span>; port<span>\u00a0<\/span><\/span><span class=\"system\">9000<\/span><span><span>\u00a0<\/span>might be in use by Debian&#8217;s default PHP-FPM already):<\/span><\/p>\n<p class=\"command\">nano\u00a0\/opt\/php-7.2\/etc\/php-fpm.d\/www.conf<\/p>\n<pre>[...]&#13;\nlisten = 127.0.0.1:8998&#13;\n[...]<\/pre>\n<h3 id=\"-create-the-systemd-unit-file-2\">4.1 Create the systemd unit file<\/h3>\n<p>Next, we&#8217;ll create the system unit file which is used to start and stop the PHP-FPM daemon.<\/p>\n<p class=\"command\">nano\u00a0\/lib\/systemd\/system\/php-7.2-fpm.service<\/p>\n<p>with the following content:<\/p>\n<pre readability=\"8\">[Unit]<br\/>Description=The PHP 7.2 FastCGI Process Manager<br\/>After=network.target[Service]<br\/>Type=simple<br\/>PIDFile=\/opt\/php-7.2\/var\/run\/php-fpm.pid<br\/>ExecStart=\/opt\/php-7.2\/sbin\/php-fpm --nodaemonize --fpm-config \/opt\/php-7.2\/etc\/php-fpm.conf<br\/>ExecReload=\/bin\/kill -USR2 $MAINPID<\/p>[Install]<br\/>WantedBy=multi-user.target<\/p><\/pre>\n<p>Enable the service and reload systemd:<\/p>\n<p class=\"command\"><span>systemctl enable php-7.2-fpm.service<\/span><br \/>systemctl daemon-reload<\/p>\n<p>Finally, start PHP-FPM.<\/p>\n<p class=\"command\">systemctl start php-7.2-fpm.service<\/p>\n<p>To enable the Zend OPcache, open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-7.2\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-7.2\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nzend_extension=opcache.so<\/pre>\n<h3 id=\"-enable-memcache-optional\">4.2 Enable Memcache (optional)<\/h3>\n<p>In this chapter, I will compile and enable the PHP Memcached extension.<\/p>\n<p>The first step is to install the\u00a0<span>libmemcached-dev package from Debian.<\/span><\/p>\n<p class=\"command\">apt-get install libmemcached-dev<\/p>\n<p>Then create a diretory, download the PHP memcache extension from Github, unpack the archive and enter the directory that contains the unpacked files.<\/p>\n<p class=\"command\">mkdir \/usr\/local\/src\/php7.2-build\/php-memcache<br \/>cd \/usr\/local\/src\/php7.2-build\/php-memcache<br \/>wget https:\/\/github.com\/php-memcached-dev\/php-memcached\/archive\/php7.zip<br \/>unzip php7.zip<br \/>cd php-memcached-php7<\/p>\n<p>Prepare he sources by running the phpize command from PHP 7.2.<\/p>\n<p class=\"command\">\/opt\/php-7.2\/bin\/phpize<\/p>\n<p>Configure and build the PHP memcache extension.<\/p>\n<p class=\"command\">.\/configure &#8211;with-php-config=\/opt\/php-7.2\/bin\/php-config<br \/>make<br \/>make install<\/p>\n<p>To enable the Memcache extension, open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-7.2\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-7.2\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nextension=memcached.so<\/pre>\n<h3 id=\"-install-xdebug-extension-optional\">4.3 Install xDebug extension (optional)<\/h3>\n<p>The<span>\u00a0<\/span><a href=\"https:\/\/xdebug.org\/docs\/install\" target=\"_blank\" rel=\"noopener\">xDebug<\/a>\u00a0module is a debugging extension for PHP. The installation is optional.<\/p>\n<p>Install xDebug with these commands.<\/p>\n<p class=\"command\">cd \/opt\/php-7.2\/etc<br \/>pecl -C .\/pear.conf update-channels<br \/>pecl -C .\/pear.conf install xdebug<\/p>\n<p>Then edit the php.ini file with an editor:<\/p>\n<p class=\"command\">nano \/opt\/php-7.2\/lib\/php.ini<\/p>\n<p>and add the following line at the end of the file:<\/p>\n<pre>zend_extension=\/opt\/php-7.2\/lib\/php\/extensions\/no-debug-non-zts-20170718\/xdebug.so<\/pre>\n<p>Finally restart the php-fpm daemon:<\/p>\n<p class=\"command\"><span>systemctl start\u00a0<\/span>php<span>-7.2-fpm.service<\/span><\/p>\n<p>Test the PHP version:<\/p>\n<p class=\"command\">cd\u00a0\/opt\/php-7.2\/bin<br \/>.\/php &#8211;version<\/p>\n<p>The output should be similar to this screenshot.<\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.2-debian_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.2-debian_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-4.png\" alt=\"PHP 7.2 installed on Debian 9\" width=\"550\" height=\"56\" title=\"\"><\/a><\/p>\n<p><strong>Please note:<\/strong><span>\u00a0<\/span>The screenshot is from PHP 7.2.2,\u00a0the tutorial gets updated continuously for new PHP versions but we don&#8217;t take new screenshots each time, so the PHP version that you will see on your server might be newer. The current version of this tutorial is for\u00a0<span>php-7.2.2.<\/span><\/p>\n<h3 id=\"-enable-php-in-ispconfig-2\">4.4 Enable PHP 7.2 in ISPConfig<\/h3>\n<p>In ISPConfig 3.1, you can configure the new PHP version under<span>\u00a0<\/span><span class=\"system\">System &gt; Additional PHP Versions<\/span>. On the<span>\u00a0<\/span><span class=\"system\">Name<\/span><span>\u00a0<\/span>tab, you just fill in a name for the PHP version (e.g.<span>\u00a0<\/span><span class=\"system\">PHP 7.2<\/span>) &#8211; this PHP version will be listed under this name in the website settings in ISPConfig:<\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.2-name_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.2-name_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-5.png\" alt=\"PHP 7.2\" width=\"550\" height=\"254\" title=\"\"><\/a><\/p>\n<p><span>Go to the<span>\u00a0<\/span><\/span><span class=\"system\">FastCGI Settings<\/span><span><span>\u00a0<\/span>tab<span>\u00a0<\/span><\/span><span>and fill out the fields as follows:<\/span><\/p>\n<p class=\"system\"><span><strong>Path to the PHP FastCGI binary:<\/strong>\u00a0\/opt\/php-7.2\/bin\/php-cgi<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-7.2\/lib<\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.2-fcgi_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.2-fcgi_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-6.png\" alt=\"PHP 7.1 FCGI\" width=\"550\" height=\"225\" title=\"\"><\/a><\/p>\n<p>Then g\u00a0to the<span>\u00a0<\/span><span class=\"system\">PHP-FPM Settings<\/span><span>\u00a0<\/span>tab\u00a0and fill out the fields as follows:<\/p>\n<p class=\"system\"><span><strong>Path to the PHP-FPM init script:<\/strong>\u00a0php-7.2-fpm<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-7.2\/lib<br \/><strong>Path to the PHP-FPM pool directory:<\/strong>\u00a0\/opt\/php-7.2\/etc\/php-fpm.d<br \/><\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-7.2-fpm_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-7.2-fpm_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-7.png\" alt=\"PHP 7.2 FPM\" width=\"550\" height=\"259\" title=\"\"><\/a><\/p>\n<h2 id=\"nbspcompilenbspphpnbsp-as-phpfpm-and-fastcgi\">5\u00a0Compile\u00a0PHP\u00a05.6 as PHP-FPM and Fastcgi<\/h2>\n<p>Download PHP and unpack the tar.bz2 archive:<\/p>\n<p class=\"command\">mkdir -p \/opt\/php-5.6<br \/>mkdir \/usr\/local\/src\/php5.6-build<br \/>cd \/usr\/local\/src\/php5.6-build<br \/>wget http:\/\/de2.php.net\/get\/php-5.6.33.tar.bz2\/from\/this\/mirror\u00a0-O php-5.6.33.tar.bz2<br \/>tar jxf php-5.6.33.tar.bz2<\/p>\n<p>Enter the folder which contains the unpacked PHP surce files.<\/p>\n<p class=\"command\">cd\u00a0php-5.6.33\/<\/p>\n<p>The OpenSSL version in Debian 9 is too new for PHP 5.6, so we&#8217;ll have to compile an older version in \/opt\/openssl to use it with PHP 5.6.<\/p>\n<p class=\"command\">cd \/tmp<br \/>wget &#8220;https:\/\/www.openssl.org\/source\/old\/1.0.1\/openssl-1.0.1t.tar.gz&#8221;<br \/>tar xzf openssl-1.0.1t.tar.gz <br \/>cd openssl-1.0.1t<br \/>.\/config shared &#8211;prefix=\/opt\/openssl<br \/>make -j $(nproc) &amp;&amp; make install<br \/>ln -s \/opt\/openssl\/lib \/opt\/openssl\/lib\/x86_64-linux-gnu<br \/>wget -O \/opt\/openssl\/ssl\/cert.pem &#8220;http:\/\/curl.haxx.se\/ca\/cacert.pem&#8221;<\/p>\n<p>Create a symlink so PHP will find the freetype, libcrypto and libssl libraries.<\/p>\n<p class=\"command\">mkdir \/usr\/include\/freetype2\/freetype<br \/>ln -s \/usr\/include\/freetype2\/freetype.h \/usr\/include\/freetype2\/freetype\/freetype.h<br \/>ln -s \/opt\/openssl\/lib\/libcrypto.so.1.0.0 \/usr\/lib\/x86_64-linux-gnu\/<br \/>ln -s \/opt\/openssl\/lib\/libssl.so.1.0.0 \/usr\/lib\/x86_64-linux-gnu\/<\/p>\n<p>Configure and build PHP 5.6 as follows (you can adjust the<span>\u00a0<\/span><span class=\"system\">.\/configure<\/span><span>\u00a0<\/span>command to your needs, take a look at<\/p>\n<p class=\"command\">.\/configure &#8211;help<\/p>\n<p>to see all available options; if you use a different<span>\u00a0<\/span><span class=\"system\">.\/configure<\/span><span>\u00a0<\/span>command, it is possible that additional libraries are required, or the build process will fail):<\/p>\n<p class=\"command\"><span>.\/configure &#8211;prefix=\/opt\/php-5.6 &#8211;with-pdo-pgsql &#8211;with-zlib-dir &#8211;with-freetype-dir &#8211;enable-mbstring &#8211;with-libxml-dir=\/usr &#8211;enable-soap &#8211;enable-calendar &#8211;with-curl &#8211;with-mcrypt &#8211;with-zlib &#8211;with-pgsql &#8211;disable-rpath &#8211;enable-inline-optimization &#8211;with-bz2 &#8211;with-zlib &#8211;enable-sockets &#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-pcntl &#8211;enable-mbregex &#8211;enable-exif &#8211;enable-bcmath &#8211;with-mhash &#8211;enable-zip &#8211;with-pcre-regex &#8211;with-pdo-mysql &#8211;with-mysqli &#8211;with-mysql-sock=\/var\/run\/mysqld\/mysqld.sock\u00a0&#8211;with-jpeg-dir=\/usr &#8211;with-png-dir=\/usr &#8211;enable-gd-native-ttf &#8211;with-openssl=\/opt\/openssl &#8211;with-fpm-user=www-data &#8211;with-fpm-group=www-data &#8211;with-libdir=\/lib\/x86_64-linux-gnu &#8211;enable-ftp &#8211;with-imap &#8211;with-imap-ssl &#8211;with-kerberos &#8211;with-gettext &#8211;with-xmlrpc &#8211;with-xsl &#8211;enable-opcache &#8211;enable-fpm<\/span><\/p>\n<p>The last switch (<span class=\"system\">&#8211;enable-fpm<\/span>) makes sure this PHP version will work with PHP-FPM.<\/p>\n<p class=\"command\">make<br \/>make install<\/p>\n<p>Copy<span>\u00a0<\/span><span class=\"system\">php.ini<\/span><span>\u00a0<\/span>and<span>\u00a0<\/span><span class=\"system\">php-fpm.conf<\/span><span>\u00a0<\/span>to the correct locations:<\/p>\n<p class=\"command\">cp \/usr\/local\/src\/php5.6-build\/<span>php-5.6.33<\/span>\/php.ini-production \/opt\/php-5.6\/lib\/php.ini<\/p>\n<p class=\"command\">cp \/opt\/php-5.6\/etc\/php-fpm.conf.default \/opt\/php-5.6\/etc\/php-fpm.conf<\/p>\n<p>Open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-5.6\/etc\/php-fpm.conf<\/span><span>\u00a0<\/span>and adjust the following setting:<\/p>\n<p class=\"command\">nano \/opt\/php-5.6\/etc\/php-fpm.conf<\/p>\n<pre>[...]&#13;\npid = run\/php-fpm.pid&#13;\n[...]&#13;\nuser = www-data&#13;\ngroup = www-data&#13;\n[...]&#13;\nlisten = 127.0.0.1:8999&#13;\n[...]&#13;\ninclude=\/opt\/php-5.6.30\/etc\/<span>php-fpm.d<\/span>\/*.conf<\/pre>\n<h3 id=\"-create-the-systemd-unit-file-3\">5.1 Create the systemd unit file<\/h3>\n<p>Next, we&#8217;ll create the system unit file which is used to start and stop the PHP-FPM daemon.<\/p>\n<p class=\"command\">nano\u00a0\/lib\/systemd\/system\/php-5.6-fpm.service<\/p>\n<p>with the following content:<\/p>\n<pre readability=\"8\">[Unit]<br\/>Description=The PHP 5.6 FastCGI Process Manager<br\/>After=network.target[Service]<br\/>Type=simple<br\/>PIDFile=\/opt\/php-5.6\/var\/run\/php-fpm.pid<br\/>ExecStart=\/opt\/php-5.6\/sbin\/php-fpm --nodaemonize --fpm-config \/opt\/php-5.6\/etc\/php-fpm.conf<br\/>ExecReload=\/bin\/kill -USR2 $MAINPID<\/p>[Install]<br\/>WantedBy=multi-user.target<\/p><\/pre>\n<p>Enable the service and reload systemd:<\/p>\n<p class=\"command\"><span>systemctl enable php-5.6-fpm.service<\/span><br \/>systemctl daemon-reload<\/p>\n<p>Finally, start PHP-FPM.<\/p>\n<p class=\"command\">systemctl start php-5.6-fpm.service<\/p>\n<p>To enable the Zend OPcache, open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-5.6\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-5.6\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nzend_extension=opcache.so<\/pre>\n<h3 id=\"-enable-memcache-optional\">5.2 Enable Memcache (optional)<\/h3>\n<p>In this chapter, I will compile and enable the PHP Memcached extension.<\/p>\n<p>The first step is to install the\u00a0<span>libmemcached-dev package from Debian.<\/span><\/p>\n<p class=\"command\">apt-get install libmemcached-dev<\/p>\n<p>Then\u00a0run these commands to build the memcache extension<\/p>\n<p class=\"command\"><span>cd \/opt\/php-5.6\/etc<\/span><br \/><span>pecl -C .\/pear.conf update-channels<\/span><br \/><span>pecl -C .\/pear.conf install\u00a0memcache<\/span><\/p>\n<p>To enable the Memcache extension, open<span>\u00a0<\/span><span class=\"system\">\/opt\/php-5.6\/lib\/php.ini<\/span>&#8230;<\/p>\n<p class=\"command\">nano \/opt\/php-5.6\/lib\/php.ini<\/p>\n<p>&#8230; and add the following line at the end:<\/p>\n<pre>[...]&#13;\nextension=memcache.so<\/pre>\n<p>Finally restart the php-fpm daemon:<\/p>\n<p class=\"command\"><span>systemctl start\u00a0<\/span>php<span>-5.6-fpm.service<\/span><\/p>\n<p>Test the PHP version:<\/p>\n<p class=\"command\">cd\u00a0\/opt\/php-5.6\/bin<br \/>.\/php &#8211;version<\/p>\n<p>The output should be similar to this screenshot.<\/p>\n<p><a class=\"fancybox\" id=\"img-php-5.6-debian-9_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-5.6-debian-9_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-8.png\" alt=\"PHP 5.6 compiled on Debian 9\" width=\"550\" height=\"55\" title=\"\"><\/a><\/p>\n<p><strong>Please note:<\/strong><span>\u00a0<\/span>The screenshot is from PHP 5.6.33,\u00a0the tutorial gets updated continuously for new PHP versions but we don&#8217;t take new screenshots each time, so the PHP version that you will see on your server might be newer. The current version of this tutorial is for\u00a0<span>php-5.6.33.<\/span><\/p>\n<h3 id=\"-enable-php-in-ispconfig-3\">5.4 Enable PHP 5.6 in ISPConfig<\/h3>\n<p>In ISPConfig 3.1, you can configure the new PHP version under<span>\u00a0<\/span><span class=\"system\">System &gt; Additional PHP Versions<\/span>. On the<span>\u00a0<\/span><span class=\"system\">Name<\/span><span>\u00a0<\/span>tab, you just fill in a name for the PHP version (e.g.<span>\u00a0<\/span><span class=\"system\">PHP 5.6<\/span>) &#8211; this PHP version will be listed under this name in the website settings in ISPConfig:<\/p>\n<p><a class=\"fancybox\" id=\"img-php-5.6-name_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-5.6-name_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-9.png\" alt=\"PHP 5.6\" width=\"550\" height=\"256\" title=\"\"><\/a><\/p>\n<p><span>Go to the<span>\u00a0<\/span><\/span><span class=\"system\">FastCGI Settings<\/span><span><span>\u00a0<\/span>tab<span>\u00a0<\/span><\/span><span>and fill out the fields as follows:<\/span><\/p>\n<p class=\"system\"><span><strong>Path to the PHP FastCGI binary:<\/strong>\u00a0\/opt\/php-5.6\/bin\/php-cgi<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-5.6\/lib<\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-5.6-fcgi_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-5.6-fcgi_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-10.png\" alt=\"PHP 5.6 FCGI\" width=\"550\" height=\"227\" title=\"\"><\/a><\/p>\n<p>Then g\u00a0to the<span>\u00a0<\/span><span class=\"system\">PHP-FPM Settings<\/span><span>\u00a0<\/span>tab\u00a0and fill out the fields as follows:<\/p>\n<p class=\"system\"><span><strong>Path to the PHP-FPM init script:<\/strong>\u00a0php-5.6-fpm<br \/><strong>Path to the php.ini directory:<\/strong>\u00a0\/opt\/php-5.6\/lib<br \/><strong>Path to the PHP-FPM pool directory:<\/strong>\u00a0\/opt\/php-5.6\/etc\/php-fpm.d<br \/><\/span><\/p>\n<p><a class=\"fancybox\" id=\"img-php-5.6-fpm_\" href=\"https:\/\/www.howtoforge.com\/images\/how-to-install-php-5.6-and-7.1-on-debian-9-stretch\/big\/php-5.6-fpm_.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/02\/how-to-install-php-7-1-7-2-and-5-6-as-php-fpm-fastcgi-for-ispconfig-3-on-debian-9-11.png\" alt=\"PHP 5.6 FPM\" width=\"550\" height=\"259\" title=\"\"><\/a><\/p>\n<h2 id=\"-links\">6 Links<\/h2>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Debian 9 ships with PHP 7.0 as default PHP version. Major PHP versions are not 100% compatible with each other, so a website might require a newer or older PHP version to work. ISPConfig supports it to use multiple PHP versions on the same server, the PHP version can be selected for each website individually &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-2849","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2849","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=2849"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/2849\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=2849"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=2849"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=2849"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}