代码之家  ›  专栏  ›  技术社区  ›  Kim

brew安装php56 imagick:没有可用公式

  •  1
  • Kim  · 技术社区  · 7 年前

    我在OSX High Sierra上,试图通过 brew install 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. .

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

    谢谢 基姆

    1 回复  |  直到 7 年前
        1
  •  0
  •   Hanxue    7 年前

    php56-imagick 以及以前在 Homebrew/php tap,但它们已被弃用。安装PHP扩展的标准方法是使用 pecl ,例如:

    pecl install imagick
    

    为特定版本的PHP安装扩展

    公式 php56-imagick 假设您需要PHP5.6的扩展。将PHP5.6的安装目录添加到 PATH 以便您使用的是正确版本的 佩克尔 .

    $ 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/cell/php@7.1/7.1.16_1/pecl/20160303

    这是由于失踪的 /usr/local/lib/php/pecl 目录这可能是因为我一直在使用PHP5。在PHP7发布之前使用x,因此较新的安装不会创建目录。无论如何,创建目录解决了这个问题

    mkdir /usr/local/lib/php/pecl
    

    编译扩展目录

    请注意,每个版本的PHP(通过自制软件安装)都位于 /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扩展配置

    佩克尔 有助于添加行

     extension="imagick.so"
    

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

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

    最后,记住重新加载或重新启动web服务器!

    推荐文章