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

All

Linux Articles / All 64 Views comments

Ubuntu 18.04 ships with PHP 7.2 as default PHP model. Main PHP variations aren't 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 may be chosen for every web site individually within the web site settings. This tutorial exhibits methods 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 Word

I'll set up PHP 7.Four. Please word that PHP-FPM can be utilized on each Apache and Nginx servers whereas FastCGI is accessible 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 in case 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/php-7.Four.zero

)

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

Obtain and extract PHP archive:

cd /tmp
wget https://www.php.internet/distributions/php-7.Four.zero.tar.gz
tar xfz php-7.Four.zero.tar.gz
cd php-7.Four.zero

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

./configure --help

to see all out there choices; when you use a unique ./configure command, it's attainable 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
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 forth/php-fpm.d/www.conf.default /choose/php-7.Four/and so forth/php-fpm.d/www.conf

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

sed -i 's/;pid = run/php-fpm.pid/pid = run/php-fpm.pid/g' /choose/php-7.Four/and so forth/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 on/php-fpm.d/www.conf

If in case you have already further PHP-versions put in, please verify, that the port is just not already in use:

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

In the event 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:

[Unit]
Description=The PHP 7.Four FastCGI Course of Supervisor
After=community.goal

[Service]
Sort=easy
PIDFile=/choose/php-7.Four/var/run/php-fpm.pid
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

[Install]
WantedBy=multi-user.goal

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 zend_extension=opcache.so >> /choose/php-7.Four/lib/php.ini

three.2 Allow Memcache (elective)

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 extension=memcached.so >> /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 optionally available.

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/xdebug.so >> /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'll be able to configure the brand new PHP model beneath 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 might 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 on/php-fpm.d

Comments