【问题标题】:brew install php56-imagick: No available formulabrew install php56-imagick:没有可用的公式
【发布时间】:2018-11-29 03:37:57
【问题描述】:

我在 OSX High Sierra 上并尝试通过 brew install php56-imagick 安装 php56-imagick。这导致:

Error: No available formula with the name "php56-imagick" 
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

我尝试在互联网上阅读此内容brew tap Homebrew/homebrew-php,但它返回:Error: homebrew/php was deprecated. This tap is now empty as all its formulae were migrated.

在哪里可以找到安装此软件包的公式?

谢谢, 金

【问题讨论】:

标签: homebrew macos-high-sierra


【解决方案1】:

php56-imagick 和其他 PHP 扩展过去可以在 Homebrew/php 点击中使用,但它们已被弃用。安装 PHP 扩展的标准方式是使用pecl,例如:

pecl install imagick

为特定版本的 PHP 安装扩展

公式php56-imagick 假设您需要 PHP 5.6 的扩展。将 PHP 5.6 的安装目录添加到您的 PATH 中,以便您使用正确版本的 pecl

$ PATH=/usr/local/opt/php@5.6/bin:/usr/local/opt/php@5.6/sbin:$PATH pecl install imagick
downloading imagick-3.4.3.tgz ...
Starting to download imagick-3.4.3.tgz (245,410 bytes)
...................................................done: 245,410 bytes
19 source files, building
running: phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
...
...
...
Build process completed successfully
Installing '/usr/local/Cellar/php@5.6/5.6.35_1/include/php/ext/imagick/php_imagick_shared.h'
Installing '/usr/local/Cellar/php@5.6/5.6.35_1/pecl/20131226/imagick.so'
install ok: channel://pecl.php.net/imagick-3.4.3
Extension imagick enabled in php.ini

扩展安装错误

在我的扩展安装过程中,我遇到了这个错误

错误:无法 mkdir /usr/local/Cellar/php@7.1/7.1.16_1/pecl/20160303

这是因为缺少 /usr/local/lib/php/pecl 目录。这可能是因为我在 PHP 7 发布之前一直在使用 PHP 5.x,因此较新的安装不会创建目录。无论如何,创建目录解决了这个问题

mkdir /usr/local/lib/php/pecl

编译的扩展目录

请注意,每个版本的 PHP(通过 Homebrew 安装)都位于 /usr/local/lib/php/pecl

$ ls -ld /usr/local/Cellar/php@5.6/5.6.35_1/pecl
lrwxr-xr-x  1 hanxue  admin  23 Apr 25  2018 /usr/local/Cellar/php@5.6/5.6.35_1/pecl -> /usr/local/lib/php/pecl

每个 PHP 版本都有自己的扩展目录

$ ls /usr/local/lib/php/pecl/20131226/
imagick.so

php.ini 扩展配置

pecl 帮助添加行

 extension="imagick.so"

php.ini 的顶部,但未设置`extension_dir。将其设置为正确的值

extension_dir = "/usr/local/lib/php/pecl/20131226"

最后,记得重新加载或重启你的网络服务器!

【讨论】:

    猜你喜欢
    • 2015-07-24
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    相关资源
    最近更新 更多