宝塔面板GMP PHP扩展安装不上安装失败

吾爱分享 建站运维评论33字数 2466阅读8分13秒阅读模式

在Ubuntu系统下的宝塔面板中给PHP安装GMP扩展时,安装完成后发现没有安装成功,查看PHP扩展目录后也没有见到GMP扩展文,并且尝试了多个PHP版本后都是一样安装不上。特此记录一下解决问题的过程,希望可以帮助到遇到相同问题的朋友。

排查执行日志后得知以下内容文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

Configuring for:
PHP Api Version:         20210902
Zend Module Api No:      20210902
Zend Extension Api No:   420210902
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether cc accepts -g... yes
checking for cc option to enable C11 features... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /www/server/php/81
checking for PHP includes... -I/www/server/php/81/include/php -I/www/server/php/81/include/php/main -I/www/server/php/81/include/php/TSRM -I/www/server/php/81/include/php/Zend -I/www/server/php/81/include/php/ext -I/www/server/php/81/include/php/ext/date/lib
checking for PHP extension directory... /www/server/php/81/lib/php/extensions/no-debug-non-zts-20210902
checking for PHP installed headers prefix... /www/server/php/81/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... gawk
checking for GNU MP support... yes, shared
checking for __gmpz_rootrem in -lgmp... no
configure: error: GNU MP Library version 4.2 or greater required.
make: *** No targets specified and no makefile found.  Stop.
error

分析日志信息后可知,安装脚本在尝试为 PHP 安装 GNU MP(GMP)扩展时遇到了错误。错误发生在配置阶段,具体原因是找不到满足版本要求的 GNU MP 库。下面是错误分析:文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

  1. 错误信息:
configure: error: GNU MP Library version 4.2 or greater required.
  1. 这表明配置脚本需要 GNU MP 库的版本至少为 4.2。GNU MP 是一个免费的库,用于任意精度算术,支持有符号整数、有理数和浮点数。
  2. 问题原因:
    • 您的系统中可能没有安装 GNU MP 库,或者安装的版本低于所需的 4.2 版本。
    • 配置脚本在尝试链接到 GNU MP 库时失败,可能是因为库文件不在预期的位置或者系统无法找到库文件。
  3. 解决方案:
    • 安装或更新 GNU MP 库:
      • 您需要确保 GNU MP 库已安装在您的系统上,并且版本至少为 4.2。
      • 在 Ubuntu 或 Debian 系统上,您可以使用以下命令安装或更新 GNU MP 库:
sudo apt-get update
sudo apt-get install libgmp-dev

检查库文件位置:文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

  • 确保 GNU MP 库文件(如 libgmp.so)位于系统可以访问的库路径中。
  • 您可能需要设置环境变量,如 LD_LIBRARY_PATH,以确保库文件可以被找到。

重新运行安装脚本:文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

  • 在解决了 GNU MP 库的问题后,重新运行安装脚本(或者直接去PHP扩展安装界面重新安装):
bash /www/server/panel/install/gmp.sh install 81

文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

最后问题得到解决!(如果你的错误日志是别的,也可以通过翻译或搜索你的错误信息分析报错原因,解决报错后应该就可以正常安装gmp扩展了)文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html

宝塔面板GMP PHP扩展安装不上安装失败
文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html文章源自 吾爱分享 吾爱分享网-https://www.wuaishare.cn/3428.html
吾爱分享

发表评论