15 hours ago15 hr This is a tutorial for PHP 8.4 installation in CWP PHP SwitcherI've switched to direct compiler environment variables that pass flags straight to gcc, g++, and ld - eliminating pkg-config dependency that was failing across servers.Old Method (Unstable):pkg-config → generates flags → gcc/g++/ld ↓ Breaks when pkg-config .pc files missing/corrupted/version mismatchNew Method (Stable):CFLAGS/CXXFLAGS/LDFLAGS → gcc/g++/ld directly ↓ No pkg-config intermediary = consistent builds everywhereInstall dependencies :# For el9 only : dnf config-manager --set-enabled crb # run these for el8 and el9 dnf groupinstall "Development Tools" dnf install glibc-devel elfutils-libelf-devel dnf install git make gcc gcc-c++ binutils glibc-devel autoconf libtool bison re2c automake libxml2-devel openssl-devel sqlite-devel bzip2-devel libcurl-devel libpng-devel libavif-devel libwebp-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libicu-devel openldap-devel oniguruma-devel libargon2-devel libtidy-devel libxslt-devel Build PHP 8.4 switcher :rm -rf /usr/local/php-84 mkdir -p /usr/local/php-84 cd /usr/local/php-84 wget http://php.net/distributions/php-8.4.15.tar.gz tar zxvf php-8.4.15.tar.gz cd php-8.4.15 ./configure --with-config-file-path=/usr/local/php --enable-cgi --with-config-file-scan-dir=/usr/local/php/php.d --with-zlib=/usr --enable-mbstring --with-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --with-curl --with-iconv --with-gmp --enable-gd --with-avif --with-jpeg --with-freetype --enable-gd-jis-conv --with-webp --with-xpm --with-openssl --with-pdo-mysql=mysqlnd --with-gettext=/usr --with-bz2=/usr --with-mysqli --enable-soap --enable-phar --with-xsl --enable-posix --enable-sockets --with-external-pcre --with-libdir=lib64 --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-intl --with-password-argon2 --enable-litespeed --with-ldap=/usr --with-ldap-sasl=/usr export CFLAGS="-O2 -fPIE -DPIC" export CXXFLAGS="-O2 -fPIE -DPIC" export LDFLAGS="-pie -Wl,--as-needed" make -j$(nproc) make installAfter that, PHP 8.4 will be installed. You can check via the php -v command :[root@alma]# php -v PHP 8.4.15 (cli) (built: Dec 3 2025 01:45:34) (NTS) Copyright (c) The PHP Group Zend Engine v4.4.15, Copyright (c) Zend Technologies
4 hours ago4 hr Hello @Sandeep B. Thank you for the tutorial.I ran into a few problems under AlmaLinux 9.6, which this installation script has already fixed.#!/bin/bash set -euo pipefail set -x # For el9 only : dnf config-manager --set-enabled crb # run these for el8 and el9 dnf -y groupinstall "Development Tools" dnf -y install glibc-devel elfutils-libelf-devel dnf -y install git make gcc gcc-c++ \ binutils glibc-devel autoconf libtool \ bison re2c automake libxml2-devel openssl-devel \ sqlite-devel bzip2-devel libcurl-devel libpng-devel \ libavif-devel libwebp-devel libjpeg-devel \ libXpm-devel freetype-devel gmp-devel \ libicu-devel openldap-devel oniguruma-devel \ libargon2-devel libtidy-devel libxslt-devel # Build PHP 8.4 switcher: rm -rf /usr/local/php-84 mkdir -p /usr/local/php-84 cd /usr/local/php-84 wget http://php.net/distributions/php-8.4.15.tar.gz tar zxvf php-8.4.15.tar.gz cd php-8.4.15 # For el9 mandatory: --with-openssl=/usr/lib64 ./configure --with-config-file-path=/usr/local/php \ --enable-cgi \ --with-config-file-scan-dir=/usr/local/php/php.d \ --with-zlib=/usr \ --enable-mbstring \ --with-zip \ --enable-bcmath \ --enable-pcntl \ --enable-ftp \ --enable-exif \ --enable-calendar \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --with-tidy \ --with-curl \ --with-iconv \ --with-gmp \ --enable-gd \ --with-avif \ --with-jpeg \ --with-freetype \ --enable-gd-jis-conv \ --with-webp \ --with-xpm \ --with-openssl=/usr/lib64 \ --with-pdo-mysql=mysqlnd \ --with-gettext=/usr \ --with-bz2=/usr \ --with-mysqli \ --enable-soap \ --enable-phar \ --with-xsl \ --enable-posix \ --enable-sockets \ --with-external-pcre \ --with-libdir=lib64 \ --with-mysql-sock=/var/lib/mysql/mysql.sock \ --enable-intl \ --with-password-argon2 \ --enable-litespeed \ --with-ldap=/usr \ --with-ldap-sasl=/usr \ --with-pear \ --with-sodium # These settings will break on el9 - AlmaLinux 9.6 # export CFLAGS="-O2 -fPIE -DPIC" # export CXXFLAGS="-O2 -fPIE -DPIC" # export LDFLAGS="-pie -Wl,--as-needed" export PKG_CONFIG_PATH=/usr/lib64/pkgconfig export CFLAGS="-O2" export CXXFLAGS="-O2" export LDFLAGS="-L/usr/lib64 -Wl,--as-needed" make -j$(nproc) make install # ---------- remove old .ini from PHP 5.x, 7.x ----- rm -f /usr/local/php/php.d/sodium.ini # ---------- PECL IMAGICK INSTALL ---------- echo "Installing Imagick dependencies…" dnf -y install ImageMagick ImageMagick-devel echo "Installing Imagick via PECL…" /usr/local/bin/pecl install imagick echo "Adding imagick.ini…" mkdir -p /usr/local/php/php.d echo "extension=imagick.so" > /usr/local/php/php.d/imagick.ini echo "PHP CLI build with Imagick completed successfully!" php -v php -m | grep imagick --with-openssl=/usr/lib64 --with-pear --with-sodium without the switches and with the recommended FLAG settings, PHP 8.4.15 did not compile properly.And it may also be necessary to remove the old sodium.ini if it was left in the directory from PHP 5.x, 7.x.rm -f /usr/local/php/php.d/sodium.iniBut with the above settings, all parts of PHP 8.4.15 are compiling properly in AlmaLinux 9.6.[root@vps ~]# php -i | grep -i sodium Configure Command => './configure' '--with-config-file-path=/usr/local/php' '--enable-cgi' '--with-config-file-scan-dir=/usr/local/php/php.d' '--with-zlib=/usr' '--enable-mbstring' '--with-zip' '--enable-bcmath' '--enable-pcntl' '--enable-ftp' '--enable-exif' '--enable-calendar' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--with-curl' '--with-iconv' '--with-gmp' '--enable-gd' '--with-avif' '--with-jpeg' '--with-freetype' '--enable-gd-jis-conv' '--with-webp' '--with-xpm' '--with-openssl=/usr/lib64' '--with-pdo-mysql=mysqlnd' '--with-gettext=/usr' '--with-bz2=/usr' '--with-mysqli' '--enable-soap' '--enable-phar' '--with-xsl' '--enable-posix' '--enable-sockets' '--with-external-pcre' '--with-libdir=lib64' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-intl' '--with-password-argon2' '--enable-litespeed' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-pear' '--with-sodium' sodium sodium support => enabled libsodium headers version => 1.0.18 libsodium library version => 1.0.18 [root@vps ~]# php -i | grep -i openssl Configure Command => './configure' '--with-config-file-path=/usr/local/php' '--enable-cgi' '--with-config-file-scan-dir=/usr/local/php/php.d' '--with-zlib=/usr' '--enable-mbstring' '--with-zip' '--enable-bcmath' '--enable-pcntl' '--enable-ftp' '--enable-exif' '--enable-calendar' '--enable-sysvmsg' '--enable-sysvsem' '--enable-sysvshm' '--with-tidy' '--with-curl' '--with-iconv' '--with-gmp' '--enable-gd' '--with-avif' '--with-jpeg' '--with-freetype' '--enable-gd-jis-conv' '--with-webp' '--with-xpm' '--with-openssl=/usr/lib64' '--with-pdo-mysql=mysqlnd' '--with-gettext=/usr' '--with-bz2=/usr' '--with-mysqli' '--enable-soap' '--enable-phar' '--with-xsl' '--enable-posix' '--enable-sockets' '--with-external-pcre' '--with-libdir=lib64' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-intl' '--with-password-argon2' '--enable-litespeed' '--with-ldap=/usr' '--with-ldap-sasl=/usr' '--with-pear' '--with-sodium' SSL Version => OpenSSL/3.5.1 libSSH Version => libssh/0.10.4/openssl/zlib openssl OpenSSL support => enabled OpenSSL Library Version => OpenSSL 3.5.1 1 Jul 2025 OpenSSL Header Version => OpenSSL 3.5.1 1 Jul 2025 Openssl default config => /etc/pki/tls/openssl.cnf openssl.cafile => no value => no value openssl.capath => no value => no value OpenSSL support => enabled
Create an account or sign in to comment