1

I am trying to install pecl mongodb php driver extension in a multi php (fpm) environment of a CentOS (release 7.5) server. I have three PHP versions configured as:

  • systemctl enable php72-php-fpm (default)
  • systemctl enable php80-php-fpm
  • systemctl enable php82-php-fpm (mongodb ext to be installed here)

Here are the methods I have tried so far to install the extension for php8.2:

Method #1:

Command: /opt/remi/php82/root/usr/bin/pecl install mongodb

Output: Can't find PHP headers in /usr/include/php The php-devel package is required for use of this command. ERROR: 'phpize' failed

Note: mongodb-1.15.0.tgz was downloaded before the error.


Method #2:

Command: /opt/remi/php82/root/usr/bin/pecl -d php_suffix=8.2 install mongodb

Output: sh: phpize8.2: command not found ERROR: 'phpize' failed

Note: mongodb-1.15.0.tgz was downloaded before the error.


Can anyone please help? So many thanks for reading this far.

NOTE:

  1. I have updated the pecl through:

/opt/remi/php82/root/usr/bin/pecl channel-update pecl.php.net

  1. I have installed the following:

yum install php82-php-pear

yum install php82-php-devel

  1. Normal extensions like mbstring, mysql are installed and working fine. Ex

yum install php82-php-mbstring -y

  1. Though the mongodb package in available in the remi repo, I could not manage to install it from there.

  2. The command /opt/remi/php82/root/bin/pecl config-set php_ini /opt/remi/php82/php.ini executed to update the ini file.

  3. Output of /opt/remi/php82/root/bin/pecl config-show:

Configuration (channel pecl.php.net):

Auto-discover new Channels     auto_discover    0
Default Channel                default_channel  pecl.php.net
HTTP Proxy Server Address      http_proxy       <not set>
PEAR server [DEPRECATED]       master_server    pear.php.net
Default Channel Mirror         preferred_mirror pecl.php.net
Remote Configuration File      remote_config    <not set>
PEAR executables directory     bin_dir          /usr/bin/
PEAR documentation directory   doc_dir          /opt/remi/php82/root/usr/share/doc/pecl
PHP extension directory        ext_dir          /opt/remi/php82/root/usr/lib64/php/modules
PEAR directory                 php_dir          /opt/remi/php82/root/usr/share/pear
PEAR Installer cache directory cache_dir        /var/opt/remi/php82/cache/php-pear
PEAR configuration file        cfg_dir          /etc/opt/remi/php82/pear
directory
PEAR data directory            data_dir         /opt/remi/php82/root/usr/share/pear-data
PEAR Installer download        download_dir     /tmp/pear/download
directory
Systems manpage files          man_dir          /opt/remi/php82/root/usr/share/man
directory
PEAR metadata directory        metadata_dir     /var/opt/remi/php82/lib/pear
PHP CLI/CGI binary             php_bin          /opt/remi/php82/root/usr/bin/php
php.ini location               php_ini          /etc/opt/remi/php82/php.ini
--program-prefix passed to     php_prefix       <not set>
PHP's ./configure
--program-suffix passed to     php_suffix       <not set>
PHP's ./configure
PEAR Installer temp directory  temp_dir         /var/tmp
PEAR test directory            test_dir         /opt/remi/php82/root/usr/share/tests/pecl
PEAR www files directory       www_dir          /var/opt/remi/php82/www/html
Cache TimeToLive               cache_ttl        3600
Preferred Package State        preferred_state  stable
Unix file mask                 umask            22
Debug Log Level                verbose          1
PEAR password (for             password         <not set>
maintainers)
Signature Handling Program     sig_bin          /usr/bin/gpg
Signature Key Directory        sig_keydir       /etc/opt/remi/php82/pearkeys
Signature Key Id               sig_keyid        <not set>
Package Signature Type         sig_type         gpg
PEAR username (for             username         <not set>
maintainers)
User Configuration File        Filename         /root/.pearrc
System Configuration File      Filename         /etc/opt/remi/php82/pear.conf
sariDon
  • 7,782
  • 2
  • 16
  • 27

1 Answers1

0

Updating the 'PEAR executable directory' and the 'php_ini location' in the PECL config resolved the problem:

/opt/remi/php82/root/bin/pecl config-set bin_dir /opt/remi/php82/root/bin/

/opt/remi/php82/root/bin/pecl config-set php_ini /etc/opt/remi/php82/php.ini

and then

/opt/remi/php82/root/usr/bin/pecl install mongodb

Note:

Once installed, you can add the line extension="mongodb.so" in php.ini of the desired version to activate the extension.

sariDon
  • 7,782
  • 2
  • 16
  • 27