Home / How To / 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



Ubuntu 18.04 comes with PHP 7.2 as standard PHP version. Major PHP versions are not 100% compatible with each other, so a site may 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 site separately in the site settings. This tutorial shows you how to install PHP 7.4 as FPM and FCGI mode along with PHP 7.2 on an Ubuntu 18 server. The additional PHP versions are installed in the / opt folder, so their installation does not affect the standard PHP version

1 Preliminary note

I install PHP 7.4. Note that PHP-FPM can be used on both Apache and Nginx servers, while FastCGI is only available for Apache servers.

2 Install the conditions

Install the conditions for building PHP and the nano editor that I will use to edit the configuration files:

  apt -y install build-essential nano net-tools autoconf 
  apt -y install 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 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.aebrit19659007achtecd / usr / include 
ln-s x86_64-linux-gnu / curl

(The last command is needed if you build PHP with – med-imap for otherwise ./ configure will stop with the following error:

  check for encryption in -lcrypt ... you s 
configure: error: Can't find imap-bibl iotek (libc-client.a). Check your c-client installation.
[email protected]: / tmp / php-7.4.0

)

3 Compile PHP 7.4 as PHP-FPM and Fastcgi

Download and extract PHP archive:

  cd / tmp 
wget https://www.php.net/distributions/php-7.4.0.tar.gzebrit19459011uuttar xfz php-7.4.0.tar.gz
  cd php-7.4.0 

Configure and build PHP 7.4 as follows (you can adjust the command ./ configure to your needs, take a look at

  ./ configure - help 

to see all available options; If you use another ./ configure command, additional libraries may be required, or the build process will fail):

  ./ configure --prefix = / opt / php-7.4 --med-pdo-pgsql - med-zlib-dir - with-freetype - enable-mbstring - enable-soap - enable-calendar - with-curl - with-zlib --enable-gd - -with-pgsql - deactivate-path - enable-inline optimization - with-bz2 - with -zlib - activatable-withdrawal - activatable-sysems - enable-sysvshm - enable-pcntl - enable -mbregex - enable-exif - enable-bcmath - with-mash - with-zip - with-pdo-mysql - with-mysqli - with-mysql-sock = / var / run / mysqld / mysqld .sock - with-jpeg - with-openssl - with-fpm-users = 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 - activatable-opcache - activatable-intl - with-pears --enable-fpm 

The last switch ( – enable-fpm ) ensures that this PHP version works with PHP-FPM.

  make 
make install

Copy files to the correct location:

  cp php.ini-production /opt/php-7.4/lib/php.ini
cp /opt/php-7.4/etc/php-fpm.conf.default /opt/php-7.4/etc/php-fpm.conf
cp /opt/php-7.4/etc/php-fpm.d/www.conf.default /opt/php-7.4/etc/php-fpm.d/www.confebrit19659026??Adjust  / opt / php - 7.4 / etc / php-fpm.conf  

  sed-i & # 39; s /; pid = run  /php-fpm.pid/pid = run  /php-fpm.pid/g' / opt / php-7.4 / etc / php-fpm.conf 

Then update /opt/php-7.4/etc/php-fpm.d/www.confebrit19659029 ??: Chapter19459013 section19659006facecp / opt / php- 7.4 / etc / php-fpm.d / www.conf.default /opt/php-7.4/etc/php-fpm.d/www.confebrit19659010????19459017??If you already have additional PHP versions installed, check that the port is not already in use:

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

If you use nginx as your web server, adjust /opt/php-7.4/lib/php.ini:ebrit19659006??sed -i & # 39 ; s /; date.timezone = / date.timezone = "Europe / Berlin" / g & # 39; /opt/php-7.4/lib/php.inivud19659007vardsed -i & # 39; s /; cgi.fix_pathinfo = 1 / cgi.fix_pathinfo = 0 / g & # 39; /opt/php-7.4/lib/php.inivud19659036 ?? 3.1 Creating the system d device file

Then we create the system device file that is used to start and stop PHP-FPM daemon.

  nano /lib/systemd/system/php-7.4-fpm.service Chapter19659010 Premiere with the following content: 

   [Unit] 
Description = PHP 7.4 FastCGI Process Manager
After = network. target [Service]
Type = single
PidFile = / opt / php-7.4 / var / run / php-fpm.pid
ExecStart = / opt / php-7.4 / sbin / php-fpm - -nodaemonize --fpm-config /opt/php-7.4/etc/php-fpm.conf Chapter19459011achteExecReload = / bin / kill -USR2 $ MAINPID

[Install]
WantedBy = multi-user.target

[19659010] Activate service and reload systemd :

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

Finally, start PHP-FPM.

  systemctl start php-7.4-fpm.service 

To enable Zend OPcache:

  echo zend_extension = opcache .so >> /opt/php-7.4/lib/php.inivud19659050??3.2 Enable Memcache ( optional) 

Install memcache with these commands.

  cd /opt/php-7.4/etcebrit19459011]. ./bin/pecl -C ./pear.conf update-channel 
../ bin / pecl -C ./pear.conf install memcached

and enable memache

  echo extension = memcached.so >> /opt/php-7.4/lib/php.iniebrit19659055??3.3 Install xDebug extension (optional) 

The xDebug module is a PHP debugging extension. Installation is optional.

Install xDebug with these commands.

  cd /opt/php-7.4/etcebrit19659059vard../bin/ Tu 19199193 pecl-C./pear.conf update-channel 
../ bin / pecl -C./pear.conf install xdebug

and enable xDebug

  echo zend_extension = / opt / php-7.4 / lib / php / extensions / no-debug-non-zts-20190902 /xdebug.so >> /opt/php-7.4/lib/php.inivud19659010 ?? Finally restart the php-fpm demon: 

   systemctl start  php  -7.4-fpm.service  

Test the PHP version:

  cd / opt / php- 7.4 / binebrit19459011achte. / Php --version 

3.4 Enable PHP 7.4 in ISPConfig

In ISPConfig 3.1, you can configure the new PHP version under System> Additional PHP versions . On the Name tab, you just enter a name for the PHP version (eg PHP 7.4 ) - this PHP version will be listed under that name in the ISPConfig site settings: [19659055] Go to the tab FastCGI Settings and fill in the fields as follows:

    The path to PHP FastCGI binary:  /Opt/php-7.4/bin/ php cgiebrit19659073 ?? Path to php.ini directory:  /opt/php-7.4/libuut19659074 ?? Then go to the  PHP-FPM settings  tab and fill in the fields as follows: 

    Path to the PHP-FPM-init script:  php-7.4-fpm 
The path to the php.ini directory: /Opt/php-7.4/libebrit19659073 ?? Path to the pool catalog PHP-FPM: /opt/php-7.4/etc/php-fpm.debrit19659078??5 Links

Source link