PHP 7.4 compileren en installeren als PHP-FPM & FastCGI voor ISPConfig 3 op Ubuntu 18.04 LTS
Ubuntu 18.04 wordt geleverd met PHP 7.2 als standaard PHP versie. Belangrijke PHP versies zijn niet 100% compatibel met elkaar, dus een website kan een nieuwere of oudere PHP versie nodig hebben om te werken. ISPConfig ondersteunt het om meerdere PHP versies op dezelfde server te gebruiken, de PHP versie kan voor elke website afzonderlijk gekozen worden in de website instellingen. Deze handleiding laat zien hoe je PHP 7.4 als FPM en FCGI modus naast PHP 7.2 installeert op een Ubuntu 18 server. De extra PHP versies worden geïnstalleerd in de /opt map, zodat hun installatie geen invloed heeft op de standaard PHP versie
1 Opmerking vooraf
Ik zal PHP 7.4 installeren. Merk op dat PHP-FPM zowel op Apache als Nginx servers gebruikt kan worden, terwijl FastCGI alleen voor Apache servers beschikbaar is.
2 Installeer de eerste vereisten
Installeer de voorwaarden voor het bouwen van PHP en de nano editor die ik zal gebruiken om de configuratiebestanden te bewerken:
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/include
ln -s x86_64-linux-gnu/curl
(Het laatste commando is nodig als je PHP bouwt met –met-imap, want anders zal ./configure stoppen met de volgende foutmelding:
checking for crypt in -lcrypt... yes
configure: error: Cannot find imap library (libc-client.a). Please check your c-client installation.
[email protected]:/tmp/php-7.4.0
)
3 Compileer PHP 7.4 als PHP-FPM en Fastcgi
Download het PHP archief en pak het uit:
cd /tmp
wget https://www.php.net/distributions/php-7.4.0.tar.gz
tar xfz php-7.4.0.tar.gz
cd php-7.4.0
Configureer en bouw PHP 7.4 als volgt (je kunt het ./configure commando aan je behoeften aanpassen, kijk op
./configure --help
om alle beschikbare opties te zien; als je een ander ./configure commando gebruikt, is het mogelijk dat extra bibliotheken nodig zijn, of dat het bouwproces mislukt):
./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
De laatste schakelaar(–enable-fpm) zorgt ervoor dat deze PHP versie met PHP-FPM zal werken.
make
make install
Kopieer de bestanden naar de juiste locaties:
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
Pas /opt/php-7.4/etc/php-fpm.confaan
sed -i 's/;pid = run\/php-fpm.pid/pid = run\/php-fpm.pid/g' /opt/php-7.4/etc/php-fpm.conf
Werk dan /opt/php-7.4/etc/php-fpm.d/www.conf bij:
cp /opt/php-7.4/etc/php-fpm.d/www.conf.default /opt/php-7.4/etc/php-fpm.d/www.conf
Als je al extra PHP-versies geïnstalleerd hebt, controleer dan, of de poort niet al in gebruik is:
netstat -tapn | grep -E ".*899.*php-fpm"
Als je nginx als webserver gebruikt, pas dan /opt/php-7.4/lib/php.ini aan:
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 Maak het systemd unit bestand
Vervolgens maken we het system unit bestand dat gebruikt wordt om de PHP-FPM daemon te starten en te stoppen.
nano /lib/systemd/system/php-7.4-fpm.service
met de volgende inhoud:
[Unit]
Description=The PHP 7.4 FastCGI Process Manager
After=network.target
[Service]
Type=simple
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
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target
Schakel de dienst in en herlaad systemd:
systemctl enable php-7.4-fpm.service
systemctl daemon-reload
Start tenslotte PHP-FPM.
systemctl start php-7.4-fpm.service
Om de Zend OPcache in te schakelen:
echo zend_extension=opcache.so >> /opt/php-7.4/lib/php.ini
3.2 Schakel Memcache in (optioneel)
Installeer memcache met deze commando’s.
cd /opt/php-7.4/etc
../bin/pecl -C ./pear.conf update-channels
../bin/pecl -C ./pear.conf install memcached
en schakel memache in
echo extension=memcached.so >> /opt/php-7.4/lib/php.ini
3.3 Installeer xDebug uitbreiding (optioneel)
De xDebug module is een debugging uitbreiding voor PHP. De installatie is optioneel.
Installeer xDebug met deze commando’s.
cd /opt/php-7.4/etc
../bin/pecl -C ./pear.conf update-channels
../bin/pecl -C ./pear.conf install xdebug
en schakel xDebug in
echo zend_extension=/opt/php-7.4/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so >> /opt/php-7.4/lib/php.ini
Herstart tenslotte de php-fpm daemon:
systemctl start php-7.4-fpm.service
Test de PHP versie:
cd /opt/php-7.4/bin
./php --version
3.4 Schakel PHP 7.4 in ISPConfig in
In ISPConfig 3.1 kun je de nieuwe PHP versie instellen onder Systeem > Extra PHP Versies. Op het tabblad Name vul je gewoon een naam in voor de PHP versie (bv. PHP 7.4) – deze PHP versie zal onder deze naam vermeld worden in de website instellingen in ISPConfig:
Ga naar de FastCGI instellingen tab en vul de velden als volgt in:
Path to the PHP FastCGI binary: /opt/php-7.4/bin/php-cgi
Path to the php.ini directory: /opt/php-7.4/lib

Ga dan naar het tabblad PHP-FPM Instellingen en vul de velden als volgt in:
Path to the PHP-FPM init script: php-7.4-fpm
Path to the php.ini directory: /opt/php-7.4/lib
Path to the PHP-FPM pool directory: /opt/php-7.4/etc/php-fpm.d

5 Links
- PHP: http://www.php.net/
- ISPConfig: http://www.ispconfig.org/
- Debian: http://www.debian.org/