【问题标题】:Composer Install - requires ext-mbstringComposer 安装 - 需要 ext-mbstring
【发布时间】:2018-10-03 07:01:52
【问题描述】:

我正在尝试执行 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,但为什么我尝试composer安装时出错?

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

1:WHM - 已设置为 7.1

2:cPanel - 已设置为 7.1

但服务器中的版本仍然是 5.6

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

【问题讨论】:

标签: php apache composer-php cpanel mbstring


【解决方案1】:

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

# composer.json
# ...

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

  # ...

}

希望这对未来的其他人有用!

【讨论】:

    【解决方案2】:

    尝试使用 aptitude 安装 mbstring php 库。

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

    【讨论】:

      【解决方案3】:

      如果没有更深层次的依赖关系,您可以改用 polyfill:编辑 composer.json 并将问题行替换为 "symfony/polyfill-mbstring": "~1.0"

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

      【讨论】:

        【解决方案4】:

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

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

        【讨论】:

          【解决方案5】:

          使用此命令安装 mbstrig

           yum install php-mbstring
          

          安装后重启apache

           service httpd restart
          

          【讨论】:

          • No package php-mbstring available.
          • 重启 apache 与 Composer 没有连接,因为 Composer 不使用 Apache
          • 你们一定有一些心理问题...每次安装扩展都必须重新启动 apache。问与否,你必须每次都这样做。现在因为 apache 重启而给出否定的注释只是幼稚且毫无意义。
          • 如果我使用 NGinx 会怎样?还是要重启Apache?
          • 问题说用户正在运行 apache。
          猜你喜欢
          • 2015-04-04
          • 2018-08-11
          • 2016-10-27
          • 2017-08-07
          • 2013-04-18
          • 1970-01-01
          • 2015-10-19
          • 1970-01-01
          • 2016-06-08
          相关资源
          最近更新 更多