PHP 编译错误 Package requirements (oniguruma) were not met

Php 2020-05-28 阅读 1329 评论 0

问题描述

在 Linux/Mac 系统中,使用 PHP 7.4.6 调用 mb_convert_encoding,出现致命错误。

Error	Uncaught Error: Call to undefined function mb_convert_encoding() in /develop/php/ZolAction.php:22

编译 php-7.4.6,./configure --prefix=/opt/php-7.4.6 --with-pdo-mysql --enable-fpm --with-curl --with-zip --enable-mbstring,最后出现以下错误。

checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables ONIG_CFLAGS
and ONIG_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

解决方法

  • Mac OS
brew install oniguruma
  • Ubuntu/Debian

https://pkgs.org/download/libonig-dev下载相应版本的 libonig-dev,或者运行:

sudo apt-get install libonig-dev
  • RHEL/CentOS <= 7

在网站 https://pkgs.org/search/?q=oniguruma 下载相应的 oniguruma-devel,或者运行:

sudo yum install oniguruma-devel
  • RHEL/CentOS 8

在 Centos 8 中,官方 CentOS x86_64 存储库上的没有 oniguruma-devel,可以在网站 https://pkgs.org/search/?q=oniguruma 下载 Remi x86_64 仓库的 oniguruma-6.8.2-0.1.el8.remi.x86_64.rpmoniguruma-devel-6.8.2-0.1.el8.remi.x86_64.rpm。执行安装命令:

$ sudo yum install ./oniguruma-6.8.2-0.1.el8.remi.x86_64.rpm
$ sudo yum install ./oniguruma-devel-6.8.2-0.1.el8.remi.x86_64.rpm
最后更新 2020-05-29