【问题标题】:Installing Imagick extension on PHP 7 nightly on Ubuntu 14.04在 Ubuntu 14.04 上每晚在 PHP 7 上安装 Imagick 扩展
【发布时间】:2016-01-30 08:52:19
【问题描述】:

我安装了 ImageMagick,加上 Imagick 扩展,在 PHP 5.6 中运行良好。目前在 Ubuntu 14.04 上使用 PHP 7 nightly build,安装方式为:http://php7.zend.com/

我知道存在兼容性问题,所以我找到了这个https://github.com/mkoppanen/imagick/tree/phpseven 并尝试安装它,基本上是:

phpize ./configure make make install

然后我将 imagick.so 文件复制到 extensions_dir 并将其添加到 php.ini 并重新启动 Apache。不幸的是,这不起作用 - Imagick 没有出现在 phpinfo 中。

有谁知道如何使用 PHP 7 来实现这个功能?

非常感谢!

【问题讨论】:

  • 不要放弃我的朋友,PHP 5.6 非常不安全。
  • 这应该可以工作....如果不是有问题(呃),但如果没有更多信息,我们将无法判断是什么。你确定你编辑了正确的ini文件吗?如果是这样,您可能需要打开额外的日志记录,或者通过 strace 运行 Apache 以找出发生了什么错误。
  • 啊,我想我现在已经看到了错误。在 PHP 启动时会记录:Warning: PHP Startup: imagick: Unable to initialize module Module compiled with module API=20131226 PHP compiled with module API=20151012 These options need to match in Unknown on line 0
  • 您在该系统上也有 PHP 5.x,而 phpize 使用的是 5.x 二进制文件,而不是 php 7 中的那个。

标签: php ubuntu-14.04 imagick


【解决方案1】:

好的,所以我确实在这里犯了一些非常基本的错误,但希望不会太模糊以至于最终的解决方案不会在未来帮助某些人。

第一个问题是我确实是从 PHP 5 运行 phpize - 我以为我已经正确地符号链接了,但我没有。

除此之外,他运行的第一个命令是:

/usr/local/php7/bin/phpize

我的第二个错误是 ./configure 还假设我运行的是 PHP 5,所以要纠正这个问题,我必须运行:

./configure --with-php-config=/usr/local/php7/bin/php-config

最后,makemake install 工作并将文件自动复制到正确的位置。

感谢@Danack 的 cmets,他们提供了帮助!

【讨论】:

  • 能否请您一步一步正确地告诉我们,您是如何使用 php 7 使其工作的。我也是新手。谢谢
【解决方案2】:

试试这个指南:Install Imagick 3.4.0 on PHP 7.0 server - imagick-3.4.0-PHP7-forge.sh (Laravel Forge)。它对我来说很好。如果链接断开:

#!/bin/bash
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini
service php7.0-fpm restart
service nginx restart

【讨论】:

    猜你喜欢
    • 2011-03-03
    • 2013-01-08
    • 1970-01-01
    • 2017-10-25
    • 2020-03-07
    • 1970-01-01
    • 2020-06-20
    • 2018-09-11
    • 2021-09-13
    相关资源
    最近更新 更多