How to Compile Install PHP 7.x on AlmaLinux 10

Published: 2026-05-31
Google AdSense 广告位 (待申请通过后开启)

Introduction

This compilation and installation includes all versions 7.1-7.4, and should run without issues on Red Hat 8 and 9.

It's highly recommended to compile directly on Fedora 34 or Fedora 36, ​​as the process will be much smoother, with most dependencies already included by default, reducing the number of steps.

After compilation, simply copy the files to your AlmaLinux 10 directory, configure the environment variables, and you can run it directly—very convenient. However, compiling directly on AlmaLinux 10 is not recommended; it's almost impossible to succeed. The C++ version has also changed, and manually modifying the code is cumbersome.

Mainly, many parts of the code need to be modified, and changing one thing can cause other problems to arise, making it very troublesome. This approach is not recommended, as the dependent Python versions have also changed.

Compilation operations that are compatible with all versions are no longer possible as before. Compiling PHP 8.x directly on AlmaLinux 10 is very smooth, but it's still recommended to compile on Fedora, as it's very convenient for all versions from 7.x to 8.x.

It's recommended to use KVM to access the Fedora system for better operation. This works fine on Red Hat, Alma, or CentOS host machines, as it won't damage the main system environment and is very safe. You can experiment without worry.

First, install and resolve dependencies.

Initialize system patches

dnf install -y sqlite-devel-3.34.1-5.el9.x86_64.rpm

yum install -y libxml2 libxml2-devel

yum install -y libcurl libcurl-devel

yum install -y oniguruma oniguruma-devel

yum install -y autoconf automake libtool -y

yum install -y gd-devel

yum install -y libzip

yum install -y sqlite-devel

yum install -y gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel

dnf install -y libjpeg-devel

dnf install -y libXpm libXpm-devel

dnf install -y libwebp libwebp-devel

dnf install -y libsodium libsodium-devel

dnf install -y libxslt libxslt-devel

wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz

tar xf oniguruma-6.9.4.tar.gz

cd oniguruma-6.9.4/

./autogen.sh && ./configure --prefix=/usr

make && make install

yum install perl perl-FindBin

Install openssl-1.1.1i

wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz

tar xzf openssl-1.1.1i.tar.gz

cd openssl-1.1.1i

./Configure --prefix=/usr/local/openssl/openssl-1.1.1i/bin -fPIC -shared linux-x86_64

make -j 8

make install

export PKG_CONFIG_PATH=/usr/local/openssl/openssl-1.1.1i/bin/lib/pkgconfig

#If the shared library cannot be recognized here, add a symbolic link.

---------------error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory------

ln -s /usr/local/openssl/openssl-1.1.1i/bin/lib/libssl.so.1.1 /usr/lib64/

ln -s /usr/local/openssl/openssl-1.1.1i/bin/lib/libcrypto.so.1.1 /usr/lib64/

--------------

ll /usr/local/openssl/openssl-1.1.1i/bin/lib/pkgconfig

echo "/usr/local/openssl/openssl-1.1.1i/bin/lib" | sudo tee /etc/ld.so.conf.d/openssl-1.1.1i.conf

sudo ldconfig -v | grep libssl #openssl

PHP installation

#This installation uses version 7.4. In reality, versions 7.1 through 7.4 on Fedora are generally compatible and compatibility is good. Compiling to 8.x is also fine.

Download instructions are omitted; simply download from the official website, extract the files, and enter the root directory. Log in as root user.

Start the installation with `make clean`.

The command is as follows:

./configure --prefix=/usr/local/php7.4 --with-config-file-path=/usr/local/php7.4/etc --enable-mbstring --with-openssl --enable-ftp --enable-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl

======================================

make && make install

build/shtool install -c ext/phar/phar.phar /usr/local/php7.4/bin/phar.phar

ln -s -f phar.phar /usr/local/php7.4/bin/phar

cp php.ini-development /usr/local/php7.4/etc/

cp php.ini-production /usr/local/php7.4/etc/

cd /usr/local/php7.4/etc/

cp php.ini-development php.ini

cp php-fpm.conf.default php-fpm.conf

cp php-fpm.d/www.conf.default php-fpm.d/www.conf

php -i | grep -i freetype | grep -v configure

============================================

/usr/local/php7.4/bin/php -i | grep -i openssl

php -i | grep -i freetype | grep -v configure

/usr/local/php7.4/bin/php -i | grep -i openssl

==============================test gd freetype========

./configure --with-php-config=/usr/local/php7.4/bin/php-config --with-gd --with-freetype=/usr --with-png=/usr --with-jpeg=/usr/lib64 --with-png=/usr --with-xpm=/usr --with-webp=/usr --enable-gd --enable-freetype --enable-jpeg --enable-png --enable-gd-native-ttf

======================================================

Redis installation

wget https://pecl.php.net/get/redis-5.2.0.tgz

tar -zxvf redis-5.2.0.tgz

cd redis-5.2.0

/usr/local/php7.4/bin/phpize

./configure --with-php-config=/usr/local/php7.4/bin/php-config

make && make install

vim /usr/local/php7.4/etc/php.ini

It is usually added under the module.

;extension_dir="/usr/local/php7.4/lib/php/extensions/no-debug-non-zts-20190902" # This line can also be commented out, depending on the directory where your dependencies are compiled.

[redis]

extension="redis.so"

###############/usr/local/php7.4/lib/php/extensions/no-debug-non-zts-20190902/redis.so

Related AlmaLinux 10 Tutorials

How to Install Mysql on AlmaLinux 10

How to Install PHP Binaries on AlmaLinux 10

Explore More

Technology Guides →

How to install rabbitmq on PHP 7.x

How to use PHP Binaries PHP 7.x on AlmaLinux 10

PHP opcache.max_accelerated_files Explained: Configuration, Performance, and Best Practices

PHP opcache.validate_timestamps Explained: Configuration, Code Updates, and Best Practices

Southeast Asia Insights →