How to compile and install PHP 7.4 as PHP-FPM & FastCGI for ISPConfig 3 on Ubuntu 18.04 LTS

How to compile and install PHP 7.4 as PHP-FPM & FastCGI for ISPConfig 3 on Ubuntu 18.04 LTS


Linux Articles / All 181 Views comments

Ubuntu 18.04 ships with PHP 7.2 as default PHP model. Main PHP variations usually are not 100% suitable with one another, so an internet site may require a more moderen or older PHP model to work. ISPConfig helps it to make use of a number of PHP variations on the identical server, the PHP model might be chosen for every web site individually within the web site settings. This tutorial exhibits the way to set up PHP 7.Four as FPM and FCGI mode alongside PHP 7.2 on a Ubuntu 18 server. The extra PHP variations are put in within the /choose folder, so their set up does nit have an effect on the default PHP model

1 Preliminary Notice

I'll set up PHP 7.Four. Please observe that PHP-FPM can be utilized on each Apache and Nginx servers whereas FastCGI is out there just for Apache servers.

2 Set up the conditions

Set up the conditions for constructing PHP and the nano editor that I'll use to edit the config information:

apt -y set up build-essential nano net-tools autoconf
apt -y set up libfcgi-dev libfcgi0ldbl libjpeg-turbo8-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 libzip-dev libsqlite3-dev libonig-dev
ln -s /usr/lib/libc-client.a /usr/lib/x86_64-linux-gnu/libc-client.a
cd /usr/embrace
ln -s x86_64-linux-gnu/curl

(The final command is required should you construct PHP with --with-imap, as a result of in any other case ./configure will cease with the next error:

checking for crypt in -lcrypt... sure
configure: error: Can't discover imap library (libc-client.a). Please examine your c-client set up.
[email protected]:/tmp/


three Compile PHP 7.Four as PHP-FPM and Fastcgi

Obtain and extract PHP archive:

cd /tmp
wget https://www.php.internet/distributions/
tar xfz

Configure and construct PHP 7.Four as follows (you possibly can modify the ./configure command to your wants, check out

./configure --help

to see all out there choices; in the event you use a unique ./configure command, it's potential that further libraries are required, or the construct course of will fail):

./configure --prefix=/choose/php-7.Four --with-pdo-pgsql --with-zlib-dir --with-freetype --enable-mbstring --enable-soap --enable-calendar --with-curl --with-zlib --enable-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 --with-zip --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg --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-intl --with-pear --enable-fpm

The final change (--enable-fpm) makes positive this PHP model will work with PHP-FPM.

make set up

Copy the information to the right places:

cp php.ini-production /choose/php-7.Four/lib/php.ini
cp /choose/php-7.Four/and so on/php-fpm.conf.default /choose/php-7.Four/and so forth/php-fpm.conf
cp /choose/php-7.Four/and so on/php-fpm.d/www.conf.default /choose/php-7.Four/and so on/php-fpm.d/www.conf

Modify /choose/php-7.Four/and so forth/php-fpm.conf

sed -i 's/;pid = run/ = run/' /choose/php-7.Four/and so on/php-fpm.conf

Then replace /choose/php-7.Four/and so on/php-fpm.d/www.conf:

cp /choose/php-7.Four/and so forth/php-fpm.d/www.conf.default /choose/php-7.Four/and so forth/php-fpm.d/www.conf

In case you have already further PHP-versions put in, please verify, that the port just isn't already in use:

netstat -tapn | grep -E ".*899.*php-fpm"

Should you use nginx as your webserver, modify /choose/php-7.Four/lib/php.ini:

sed -i 's/;date.timezone =/date.timezone = "Europe/Berlin"/g' /choose/php-7.Four/lib/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=zero/g' /choose/php-7.Four/lib/php.ini

three.1 Create the systemd unit file

Subsequent, we'll create the system unit file which is used to start out and cease the PHP-FPM daemon.

nano /lib/systemd/system/php-7.Four-fpm.service

with the next content material:

Description=The PHP 7.Four FastCGI Course of Supervisor

ExecStart=/choose/php-7.Four/sbin/php-fpm --nodaemonize --fpm-config /choose/php-7.Four/and so forth/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID


Allow the service and reload systemd:

systemctl allow php-7.Four-fpm.service
systemctl daemon-reload

Lastly, begin PHP-FPM.

systemctl begin php-7.Four-fpm.service

To allow the Zend OPcache:

echo >> /choose/php-7.Four/lib/php.ini

three.2 Allow Memcache (non-compulsory)

Set up memcache with these instructions.

cd /choose/php-7.Four/and so on
../bin/pecl -C ./pear.conf update-channels
../bin/pecl -C ./pear.conf set up memcached

and allow memache

echo >> /choose/php-7.Four/lib/php.ini

three.three Set up xDebug extension (non-compulsory)

The xDebug module is a debugging extension for PHP. The set up is elective.

Set up xDebug with these instructions.

cd /choose/php-7.Four/and so forth
../bin/pecl -C ./pear.conf update-channels
../bin/pecl -C ./pear.conf set up xdebug

and allow xDebug

echo zend_extension=/choose/php-7.Four/lib/php/extensions/no-debug-non-zts-20190902/ >> /choose/php-7.Four/lib/php.ini

Lastly restart the php-fpm daemon:

systemctl begin php-7.Four-fpm.service

Check the PHP model:

cd /choose/php-7.Four/bin
./php --version

three.Four Allow PHP 7.Four in ISPConfig

In ISPConfig three.1, you possibly can configure the brand new PHP model underneath System > Further PHP Variations. On the Identify tab, you simply fill in a reputation for the PHP model (e.g. PHP 7.Four) - this PHP model will probably be listed underneath this identify within the web site settings in ISPConfig:

Go to the FastCGI Settings tab and fill out the fields as follows:

Path to the PHP FastCGI binary: /choose/php-7.Four/bin/php-cgi
Path to the php.ini listing: /choose/php-7.Four/lib

Then go to the PHP-FPM Settings tab and fill out the fields as follows:

Path to the PHP-FPM init script: php-7.Four-fpm
Path to the php.ini listing: /choose/php-7.Four/lib
Path to the PHP-FPM pool listing: /choose/php-7.Four/and so forth/php-fpm.d