تسجيل الدخول

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

2019-12-03T00:26:58+03:00
2019-12-03T00:28:16+03:00
تقنية | Technology
ebaya3 ديسمبر 2019آخر تحديث : منذ 12 شهر
How to compile and install PHP 7.4 as PHP-FPM & FastCGI for ISPConfig 3 on Ubuntu 18.04 LTS

Ubuntu 18.04 ships with PHP 7.2 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.4 as FPM and FCGI mode alongside PHP 7.2 on a Ubuntu 18 server. The additional PHP versions are installed in the /opt folder, so their installation does nit affect the default PHP version

1 Preliminary Note

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

2 Install the prerequisites

Install the prerequisites for building PHP and the nano editor that I will use to edit the config 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 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/includeln -s x86_64-linux-gnu/curl

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

checking for crypt in -lcrypt... yesconfigure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.root@server1:/tmp/php-7.4.0

)

3 Compile PHP 7.4 as PHP-FPM and Fastcgi

Download and extract PHP archive:

cd /tmpwget https://www.php.net/distributions/php-7.4.0.tar.gztar xfz php-7.4.0.tar.gz
cd php-7.4.0

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

./configure --help

to see all available options; if you use a different ./configure command, it is possible that additional libraries are required, or the build process will fail):

./configure --prefix=/opt/php-7.4 --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 last switch (–enable-fpm) makes sure this PHP version will work with PHP-FPM.

makemake install

Copy the files to the correct locations:

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.conf

Adjust /opt/php-7.4/etc/php-fpm.conf

sed -i '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.conf:

cp /opt/php-7.4/etc/php-fpm.d/www.conf.default /opt/php-7.4/etc/php-fpm.d/www.conf

If you have already additional PHP-versions installed, please check, that the port is not already in use:

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

If you use nginx as your webserver, adjust /opt/php-7.4/lib/php.ini:

sed -i 's/;date.timezone =/date.timezone = "Europe\/Berlin"/g' /opt/php-7.4/lib/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /opt/php-7.4/lib/php.ini

3.1 Create the systemd unit file

رابط مختصر

اترك تعليق

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *


شروط التعليق :

عدم الإساءة للكاتب أو للأشخاص أو للمقدسات أو مهاجمة الأديان أو الذات الالهية. والابتعاد عن التحريض الطائفي والعنصري والشتائم.