Building PHP - linux-on-ibm-z/docs GitHub Wiki
Building PHP
Below versions of PHP are available in respective distributions at the time of creation of these build instructions:
- RHEL 8.10 has
7.2.24 - RHEL (9.4, 9.6, 9.7) have
8.0.30 - RHEL (10.0, 10.1) have
8.3.26 - SLES 15 SP7 has
8.3.29 - SLES 16 has
8.4.10 - Ubuntu 22.04 has
8.1.2 - Ubuntu 24.04 has
8.3.6 - Ubuntu 25.10 has
8.4.11
The instructions provided below specify the steps to build PHP v8.5.2 on Linux on IBM Z for the following distributions:
- RHEL (8.10, 9.4, 9.6, 9.7, 10.0, 10.1)
- SLES (15 SP7, 16.0)
- Ubuntu (22.04, 24.04, 25.10)
General Notes:
- When following the steps below please use a standard permission user unless otherwise specified.
- A directory
/<source_root>/will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.
1. Build using script
If you want to build PHP using manual steps, go to STEP 2.
Use the following commands to build PHP using the build script. Please make sure you have wget installed.
wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/PHP/8.5.2/build_php.sh
# Build PHP
bash build_php.sh [Provide -t option for executing build with tests]
If the build completes successfully, PHP is installed. Proceed to Step 6 to verify installation. In case of error, check logs for more details or go to Step 2 to follow manual build steps.
2. Install prerequisites
export SOURCE_ROOT=/<source_root>/
PACKAGE_NAME="PHP"
PACKAGE_VERSION="8.5.2"
PHP_URL="https://www.php.net/distributions/php-$PACKAGE_VERSION.tar.gz"
2.1. Install the system dependencies
-
RHEL 8.10
sudo yum install -y autoconf curl libtool openssl-devel libcurl libcurl-devel libxml2 libxml2-devel readline readline-devel libzip-devel libzip nginx openssl pkgconf zlib-devel sqlite-libs sqlite-devel oniguruma oniguruma-devel libpq-devel git tar make binutils gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ bzip2 wget glibc-langpack-en -
RHEL (9.4, 9.6, 9.7, 10.0, 10.1)
sudo yum install -y autoconf libtool openssl-devel libcurl-devel libxml2 libxml2-devel readline readline-devel libzip-devel libzip nginx openssl pkgconf zlib-devel sqlite-libs sqlite-devel oniguruma oniguruma-devel libpq-devel git tar make binutils bzip2 gcc gcc-c++ wget glibc-gconv-extra glibc-locale-source -
RHEL (10.0, 10.1)
sudo yum swap libcurl-minimal libcurl --allowerasing -
SLES (15 SP7, 16.0)
sudo zypper install -y autoconf curl libtool libxml2-devel readline-devel libcurl4 libcurl-devel openssl libzip-devel pkg-config oniguruma-devel git tar sqlite3-devel zlib-devel gcc13 gcc-c++ libzip5 postgresql17 nginx postgresql17-server-devel bzip2 make gzip gawk gmp-devel mpfr-devel mpc-devel wget export CC=/usr/bin/gcc-13 export CXX=/usr/bin/g++ -
SLES (15 SP7)
sudo zypper install -y libreadline7 -
Ubuntu (22.04, 24.04, 25.10)
sudo apt-get update sudo apt-get install -y locales language-pack-de autoconf build-essential curl libtool libssl-dev libcurl4-openssl-dev libxml2-dev libreadline8 libreadline-dev libzip-dev nginx openssl pkg-config zlib1g-dev libsqlite3-dev libonig-dev libpq-dev gcc g++ git tar gcc make bzip2 wget
2.2. Set up GCC
- RHEL 8.10:
source /opt/rh/gcc-toolset-13/enable
2.3. Set up other environment variables:
-
Only on SLES:
export PREFIX=/usr/local export PATH=$PREFIX/bin${PATH:+:$PATH} [ -f /usr/bin/pg_config ] || sudo ln -s /usr/lib/postgresql17/bin/pg_config /usr/bin/pg_config PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PREFIX/lib64/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} export PKG_CONFIG_PATH LD_LIBRARY_PATH=$PREFIX/lib:$PREFIX/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} export LD_LIBRARY_PATH LD_RUN_PATH=$PREFIX/lib:$PREFIX/lib64${LD_RUN_PATH:+:$LD_RUN_PATH} export LD_RUN_PATH -
Only on RHEL and Ubuntu:
export PREFIX=/usr/local export PATH=$PREFIX/bin${PATH:+:$PATH} -
Only on RHEL:
sudo localedef -i en_US -f UTF-8 en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
3. Build PHP
-
Get the source code
cd "$SOURCE_ROOT" wget -qO- $PHP_URL | tar xzf - -
Configure and build
cd "$SOURCE_ROOT/php-$PACKAGE_VERSION" ./configure --prefix=$PREFIX \ --without-pcre-jit --without-pear \ --enable-mysqlnd --with-pdo-mysql \ --with-pdo-pgsql=/usr/bin/pg_config \ --enable-bcmath --enable-fpm --enable-mbstring \ --enable-phpdbg --enable-shmop \ --enable-sockets --enable-sysvmsg \ --enable-sysvsem --enable-sysvshm \ --with-zlib --with-curl --with-openssl \ --enable-pcntl --with-readline make -j$(nproc)
4. Run test cases (Optional)
-
Run tests (on all distros):
cd "$SOURCE_ROOT/php-$PACKAGE_VERSION" rm -f ./ext/opcache/tests/log_verbosity_bug.phpt export TEST_PHP_ARGS="-d memory_limit=2G" make TEST_PHP_ARGS="$TEST_PHP_ARGS" test -
Following Test Cases will fail on both s390x and intel:
-
RHEL (8.x, 9.x, 10.x), SLES (15 SP7, 16.0):
ext/openssl/tests/ecc_custom_params.phpt -
RHEL 9.x, 10.x:
ext/openssl/tests/gh16433.phpt ext/openssl/tests/session_meta_capture.phpt ext/openssl/tests/stream_crypto_flags_001.phpt ext/openssl/tests/stream_crypto_flags_002.phpt ext/openssl/tests/stream_crypto_flags_003.phpt ext/openssl/tests/stream_crypto_flags_004.phpt ext/openssl/tests/tls_min_v1.0_max_v1.1_wrapper.phpt ext/openssl/tests/tls_wrapper.phpt ext/openssl/tests/tls_wrapper_with_tls_v1.3.phpt ext/openssl/tests/tlsv1.0_wrapper.phpt ext/openssl/tests/tlsv1.1_wrapper.phpt ext/phar/tests/phar_setsignaturealgo2.phpt ext/phar/tests/tar/phar_setsignaturealgo2.phpt ext/phar/tests/test_signaturealgos.phpt ext/phar/tests/tar/tar_openssl_hash.phpt ext/phar/tests/zip/phar_setsignaturealgo2.phpt
Note:
- For the execution of
ext/pdo_mysql,ext/mysqliandext/pdo_pgsqltest case modules, Mysql and Postgresql server needs to be up and running. Also should have a test database and needed environment variables set. - To run individual test, you can execute the following command to execute the test by testname:
For example, if test stream_isatty_err.phpt fails, you can execute the individual test by:make test TESTS=xxxmake test TESTS=tests/output/stream_isatty_err.phpt
-
5. Install PHP
cd "$SOURCE_ROOT/php-$PACKAGE_VERSION"
sudo make install
sudo cp php.ini-development $PREFIX/lib/
6. Verify installation
/usr/local/bin/php -v
The output should be similar to:
PHP 8.5.2 (cli) (built: Jan 27 2026 08:45:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.2, Copyright (c) Zend Technologies
with Zend OPcache v8.5.2, Copyright (c), by Zend Technologies