You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CentOS7多PHP-FPM环境下安装PECL MongoDB扩展遇阻求助

在CentOS 7.5多PHP-FPM环境中为PHP 8.2安装MongoDB扩展遇到的问题

当前环境

已配置三个PHP版本:

  • systemctl enable php72-php-fpm(默认版本)
  • systemctl enable php80-php-fpm
  • systemctl enable php82-php-fpm(需在此安装MongoDB扩展)

尝试的安装方法及报错

方法一

执行命令:

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

输出报错:

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

注:报错前已下载mongodb-1.15.0.tgz


方法二

执行命令:

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

输出报错:

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

注:报错前已下载mongodb-1.15.0.tgz

已执行的操作说明

  1. 更新pecl:
/opt/remi/php82/root/usr/bin/pecl channel-update pecl.php.net
  1. 安装相关包:
yum install php82-php-pear
yum install php82-php-devel
  1. 常规扩展(如mbstring、mysql)已通过yum正常安装使用,例如:
yum install php82-php-mbstring -y
  1. 虽然remi源提供MongoDB包,但无法通过该源完成安装
  2. 已更新pecl配置:
/opt/remi/php82/root/bin/pecl config-set php_ini /opt/remi/php82/php.ini
  1. 执行/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

内容的提问来源于stack exchange,提问作者sariDon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 19:50:19