-
Notifications
You must be signed in to change notification settings - Fork 56
Building PHP
Below versions of PHP are available in respective distributions at the time of creation of these build instructions:
- RHEL (8.8, 8.10) have
7.2.24
- RHEL (9.2, 9.4, 9.5) have
8.0.30
- SLES 15 SP6 has
8.2.24
- Ubuntu 20.04 has
2:7.4+75
- Ubuntu 22.04 has
2:8.1+92
- Ubuntu (24.04, 24.10) have
2:8.3+93
The instructions provided below specify the steps to build PHP v8.4.2 on Linux on IBM Z for the following distributions:
- RHEL (8.8, 8.10, 9.2, 9.4, 9.5)
- SLES 15 SP6
- Ubuntu (20.04, 22.04, 24.04, 24.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.
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.4.2/build_php.sh
# Build PHP
bash build_php.sh [Provide -t option for executing build with tests]
If the build completes successfully, go to Step 6. In case of error, check logs
for more details or go to Step 2 to follow manual build steps.
export SOURCE_ROOT=/<source_root>/
PACKAGE_NAME="PHP"
PACKAGE_VERSION="8.4.2"
PHP_URL="https://www.php.net/distributions/php-$PACKAGE_VERSION.tar.gz"
-
RHEL (8.8, 8.10)
sudo yum install -y autoconf libtool openssl-devel libcurl libcurl-devel libxml2 libxml2-devel readline readline-devel libzip-devel libzip nginx openssl pkgconf zlib-devel bzip2 sqlite-libs sqlite-devel oniguruma oniguruma-devel libpq-devel git curl tar make binutils gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ binutils wget
-
RHEL (9.2, 9.4, 9.5)
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 gcc gcc-g++ bzip2 binutils wget
-
SLES 15 SP6
sudo zypper install -y autoconf curl libtool openssl-devel libxml2 libxml2-devel readline readline-devel libcurl4 libcurl-devel libreadline7 openssl libzip-devel pkg-config oniguruma-devel git tar sqlite3-devel zlib-devel gcc13 gcc13-c++ libzip5 postgresql16 nginx postgresql16-server-devel make gzip gawk gmp-devel mpfr-devel mpc-devel bzip2 wget export CC=/usr/bin/gcc-13 export CXX=/usr/bin/g++-13
-
Ubuntu (20.04, 22.04, 24.04, 24.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-10 g++-10 git curl tar gcc make bzip2 wget
-
Build GCC 10.3.0 and update alternative for cc (Only on Ubuntu 20.04)
ver=10.3.0 cd "$SOURCE_ROOT" url=https://ftp.gnu.org/gnu/gcc/gcc-$ver/gcc-$ver.tar.gz curl -sSL $url | tar xzf - || error "gcc $ver" cd gcc-$ver ./contrib/download_prerequisites mkdir build-gcc; cd build-gcc ../configure --enable-languages=c,c++ --disable-multilib make -j$(nproc) sudo make install sudo update-alternatives --install /usr/bin/cc cc /usr/local/bin/gcc 40
-
Set up Env variables for GCC (Only on RHEL 8.x)
source /opt/rh/gcc-toolset-13/enable
-
Set Environment (Only on SLES)
export PREFIX=/usr/local export PATH=$PREFIX/bin${PATH:+:$PATH} 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
-
Set Environment (Only on RHEL (8.x, 9.x) and Ubuntu)
export PREFIX=/usr/local export PATH=$PREFIX/bin${PATH:+:$PATH}
-
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)
-
Run tests (on all distros):
cd "$SOURCE_ROOT/php-$PACKAGE_VERSION" rm ./ext/opcache/tests/log_verbosity_bug.phpt make TEST_PHP_ARGS=-j$(nproc) test
-
Following Test Cases will fail on s390x:
- Tests
stream_isatty
: Pass on re-run.
- Tests
-
Following Test Cases will fail on both s390x and intel:
-
SLES 15 SP6:
ext/dom/tests/DOMNode_isEqualNode.phpt
-
RHEL 8.x:
ext/openssl/tests/ecc_custom_params.phpt
-
RHEL 9.x:
ext/phar/tests/phar_setsignaturealgo2.phpt ext/phar/tests/tar/phar_setsignaturealgo2.phpt ext/phar/tests/tar/tar_openssl_hash.phpt ext/phar/tests/test_signaturealgos.phpt ext/phar/tests/zip/phar_setsignaturealgo2.phpt ext/openssl/tests/ecc_custom_params.phpt ext/openssl/tests/openssl_x509_verify.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
Note:
- For the execution of
ext/pdo_mysql
,ext/mysqli
andext/pdo_pgsql
test 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=xxx
make test TESTS=tests/output/stream_isatty_err.phpt
-
cd "$SOURCE_ROOT/php-$PACKAGE_VERSION"
sudo make install
sudo cp php.ini-development $PREFIX/lib/
/usr/local/bin/php -v
The output should be similar to:
PHP 8.4.2 (cli) (built: Jan 14 2025 10:51:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.2, Copyright (c) Zend Technologies
The information provided in this article is accurate at the time of writing, but on-going development in the open-source projects involved may make the information incorrect or obsolete. Please open issue or contact us on IBM Z Community if you have any questions or feedback.