PHP 7.4.x中mbstring的正則表達式功能需要oniguruma。解決錯誤“No package 'oniguruma' found”。


一、環境:

  CentOS 7.7.1908
  PHP 7.4.2
  Oniguruma 6.9.4
二、問題:

  安裝PHP 7.4.x過程中出現如下錯誤信息:

……………………
checking whether to enable multibyte string support... yes
checking whether to enable multibyte regex support (requires oniguruma)... yes
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.

  這個錯誤信息是由於mbstring的正則功能需要oniguruma的支持,編譯PHP的時候使用了“--enable-mbstring”參數,系統中卻沒有oniguruma庫。

三、解決:

  辦法1.不使用mbstring的正則功能,即在“--enable-mbstring”后再添加“--disable-mbregex”參數。這樣的配置將不再需要oniguruma庫。

  辦法2.使用yum安裝oniguruma。

    命令:

yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-6.7.0-1.el7.x86_64.rpm
yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-devel-6.7.0-1.el7.x86_64.rpm

  辦法3.使用源代碼安裝。

    網址: https://github.com/kkos/oniguruma 

    命令:

./configure --prefix=/usr --libdir=/lib64
make
sudo make install

    簡單說明:需要有“--libdir=/lib64”參數。如果不使用這個參數,編譯PHP仍將報錯,編輯ldconfig配置無法解決問題。目前還不清楚問題的緣由。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM