Composer安装 - 需要ext-mbstring

时间:2018-04-23 09:27:32

标签: php apache composer-php cpanel mbstring

我正在尝试composer install ...,但收到错误requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.我正在使用Apache(Cpanel)和PHP 5.6。

以下是我尝试修复错误的方法。

1:yum search mbstring

============================================= N/S matched: mbstring =============================================
ea-php54-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php55-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php71-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php72-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php71-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

2:yum install ea-php56-php-mbstring.x86_64

Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 110.4.45.120
 * cpanel-addons-production-feed: 110.4.45.120
 * base: ftp.cuhk.edu.hk
 * centosplus: ftp.cuhk.edu.hk
 * epel: ftp.cuhk.edu.hk
 * extras: ftp.cuhk.edu.hk
 * ius: hkg.mirror.rackspace.com
 * updates: ftp.cuhk.edu.hk
Package ea-php56-php-mbstring-5.6.35-1.1.5.cpanel.x86_64 already installed and latest version
Nothing to do

似乎安装了mbstring,但是当我尝试编写作曲器安装时,为什么会出现错误?

另一种方式(在cPanel中更新PHP版本)

1:WHM - 已设为7.1

enter image description here

2:cPanel - 已设为7.1

enter image description here

但服务器版本仍为5.6

enter image description here

有任何解决require ext-mbstring错误的建议吗?

5 个答案:

答案 0 :(得分:1)

安装rh可以解决此问题yum install rh-php56-php-mbstring.x86_64

请仔细检查服务器中的内容。我的rh-php56-php-mbstring.x86_64不是php-mbstring

答案 1 :(得分:1)

尝试从aptitude安装mbstring php库。

sudo apt-get install php-mbstring php7.1-mbstring

答案 2 :(得分:0)

使用此命令安装mbstrig

 yum install php-mbstring

安装后重新启动apache

 service httpd restart

答案 3 :(得分:0)

如果没有更深的依赖性,则可以使用polyfill:编辑composer.json并将问题行替换为"symfony/polyfill-mbstring": "~1.0"

https://packagist.org/packages/symfony/polyfill-mbstring

答案 4 :(得分:0)

我最近尝试为我的PHP WordPress网站运行构建时遇到了类似的问题。我最终在下面的composer.json部分中用以下代码段更新了require

# composer.json
# ...

"require": {
  "ext-mbstring": "*", # <-- I've added this
  "ext-gd": "*",
  "php": "7.*",
  "wordpress/wordpress": "*",

  # ...

}

希望这将来可能对其他人有用!