Building PHP MongoDB Driver - linux-on-ibm-z/docs GitHub Wiki
Below versions of PHP Driver for MongoDB are available in respective distributions at the time of creation of these build instructions:
- RHEL (9.6, 9.7, 9.8) have
1.20.1 - Ubuntu 22.04 has
1.12.0 - Ubuntu 24.04 has
1.15.0
The instructions provided below specify the steps to build PHP Driver for MongoDB version 2.5.2 on Linux on IBM Z for following distributions:
- RHEL (8.10, 9.6, 9.7, 9.8, 10.0, 10.1, 10.2)
- SLES (15 SP7, 16)
- Ubuntu (22.04, 24.04)
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.
export SOURCE_ROOT=/<source_root>/-
RHEL 8.10
sudo yum install -y cyrus-sasl-devel gcc make openssl-devel pkgconfig compat-openssl10 wget diffutils
-
RHEL (9.6, 9.7, 9.8)
sudo yum install -y cyrus-sasl-devel gcc make openssl-devel pkgconfig wget diffutils
-
RHEL (10.0, 10.1, 10.2)
sudo yum install -y cyrus-sasl-devel gcc make openssl-devel pkgconfig wget diffutils php php-devel php-pear
-
SLES (15 SP7, 16)
sudo zypper install -y cyrus-sasl-devel gcc libopenssl-devel make php8 php8-devel php8-pecl pkg-config which gawk
-
Ubuntu (22.04, 24.04)
sudo apt-get update sudo apt-get install -y libsasl2-dev libssl-dev php php-dev pkg-config
cd $SOURCE_ROOT
wget https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/PHP/8.5.9/build_php.sh
bash build_php.sh -y
wget https://pear.php.net/go-pear.phar
php go-pear.phar
export PATH=/usr/local/lib:$SOURCE_ROOT/pear/bin:$PATH
sudo pecl install mongodb-2.5.2Notes:
- You may also use
sudo env PATH=$PATH <command>if any command fails withcommand not founderror. - If you encounter this error:
Connection to 'pecl.php.net:443' failed: Unable to find the socket transport "ssl", please run this command prior to running pecl:sudo sed -i 's|$PHP -C -n -q |$PHP -C -q |' `which pecl`
- The MongoDB PHP driver requires libbson and libmongoc, so it will use bundled versions (1.30.3) of the libraries, if they aren't present.
sudo cp /usr/local/lib/php.ini-development /usr/local/lib/php.ini (only on Rhel 8.x and 9.x)
echo -e "\n; MongoDB PHP driver\nextension=mongodb.so" | sudo tee -a /usr/local/lib/php.ini (only on rhel 8.x and 9.x)
echo -e "\n; MongoDB PHP driver\nextension=mongodb.so" | sudo tee -a `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` (for other distros)To validate the installation, refer here.