Imagick 安装错误 - 类未定义

发布于 2024-07-25 11:29:34 字数 382 浏览 4 评论 0原文

好的,以下是具体情况的详细信息:

  1. 从命令行运行时没有错误(例如 sudo php myscript.php
  2. 但是,当通过网络浏览器运行时,我收到 致命错误:在 /var 中找不到类 'Imagick'第 1 行的 /www/lhackwith_www/test_html/magic.php
  3. 未安装
  4. extension=imagick.so 位于 imagick.ini 中,根据 phpInfo() 已成功读取该文件,
  5. 但是 imagick 未显示; PHP 信息中的

任何建议将不胜感激。

Okay, Here's a breakdown of what's up:

  1. <? $foo = new Imagick(); ?> works without error when ran from the command-line (e.g., sudo php myscript.php
  2. However, when run via the web browswer I get Fatal error: Class 'Imagick' not found in /var/www/lhackwith_www/test_html/magic.php on line 1.
  3. magickwand is not installed
  4. extension=imagick.so is in imagick.ini which is successfully being read according to phpInfo();
  5. However, imagick is NOT showing up in PHP info.

Any advice would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏天碎花小短裙 2024-08-01 11:29:34

将 ubuntu 从 12.04 升级到 12.10 后,我在 imagick 上遇到了类似的问题。

经过一番摆弄,我最终发现需要一个不同的包(对于 php5?)并修复它:

sudo apt-get install php5-imagick

I had a similar problem with imagick after upgrading ubuntu from 12.04 to 12.10.

After much fiddling I eventually discovered that there is a different package needed (for php5?) and fixed it with:

sudo apt-get install php5-imagick
东风软 2024-08-01 11:29:34

我认为您绝对确定您已经编辑了正确的 php.ini...
您是否检查了网络服务器的 error.log 以获得提示? 您可能想要增加该测试的 LogLevel。 如果是 apache,请参阅 http://httpd.apache.org/docs /2.2/mod/core.html#loglevelhttp:// /httpd.apache.org/docs/2.2/logs.html#errorlog

ldd - 打印共享库依赖项 可以阐明这个问题:

<?php
$p = get_cfg_var('extension_dir');
$modpath = $p.DIRECTORY_SEPARATOR.'imagick.so';
echo $modpath, is_readable($modpath) ? ' readable':' not readable', "<br />\n";
echo '<pre>';
passthru('ldd '.$modpath.' 2>&1'); // in case of spaces et al in the path-argument use escapeshellcmd()
echo '</pre>';

please run this script both on the command line and through the webserver. Does it complain about a missing dependency?

edit2: So the script running "within" the webserver isn't even able to see the extension .so... Let's test at which point of the path the trouble starts

<?php
function foo($path) {
  if ( $path==($dir=dirname($path)) ) {
    return;
  }
  foo($dir);

回声 is_dir($路径) ? 'd': '-', 是_可读($路径)? 'r': '-', is_writable($path) ? 'w': '-', 是_可执行文件($路径)? 'X ':'- ', $path, "
\n"; $modpath = get_cfg_var('extension_dir '

).DIRECTORY_SEPARATOR.'imagick.so'; foo($modpath);

I take it you're absolutely sure you've edited the right php.ini...
Did you check the webserver's error.log for hints? You might want to increase the LogLevel for that test. If it's an apache see http://httpd.apache.org/docs/2.2/mod/core.html#loglevel and http://httpd.apache.org/docs/2.2/logs.html#errorlog

or maybe ldd - print shared library dependencies can shed some light on the issue:

<?php
$p = get_cfg_var('extension_dir');
$modpath = $p.DIRECTORY_SEPARATOR.'imagick.so';
echo $modpath, is_readable($modpath) ? ' readable':' not readable', "<br />\n";
echo '<pre>';
passthru('ldd '.$modpath.' 2>&1'); // in case of spaces et al in the path-argument use escapeshellcmd()
echo '</pre>';

please run this script both on the command line and through the webserver. Does it complain about a missing dependency?

edit2: So the script running "within" the webserver isn't even able to see the extension .so... Let's test at which point of the path the trouble starts

<?php
function foo($path) {
  if ( $path==($dir=dirname($path)) ) {
    return;
  }
  foo($dir);

echo is_dir($path) ? ' d':' -', is_readable($path) ? 'r':'-', is_writable($path) ? 'w':'-', is_executable($path) ? 'x ':'- ', $path, "<br />\n"; }

$modpath = get_cfg_var('extension_dir').DIRECTORY_SEPARATOR.'imagick.so'; foo($modpath);

画▽骨i 2024-08-01 11:29:34

您使用什么操作系统? 我在 Mac OSX 上遇到过几个问题,这些问题基本上使得安装某些扩展变得非常痛苦。 然而,对于大多数操作系统来说,Imagick 安装应该非常简单。

在命令行上输入 php -i | grep ini,并确保列出的正在加载的 php.ini 与 phpinfo() 表示正在加载的 php.ini 相同。 如果这些不同,那就是你必须开始的地方。 确保两个 ini 文件中都有 extension=imagick.so - 验证它们是否从同一目录加载扩展(99% 的机会是这样,但谁知道呢 - 你可能是个例外)。

在您验证(可能)两个 php.ini 文件都在加载 imagick.so 并且它仍然无法工作后,尝试 tail -f /path/to/apache/error_log (当然假设您使用的是 apache.. )并重新启动阿帕奇。 您正在此处查找有关加载库和/或扩展的 php 警告。 希望它能为您指明正确的方向。

希望这有帮助,

吉姆

What operating system are you using? I've had several problems on Mac OSX that basically makes installing some extensions OVERLY painful. However, the Imagick install should be really simple, for most operating systems.

On your command line, type php -i | grep ini, and make sure the php.ini that is listed as being loaded is the same as the php.ini that phpinfo() says is being loaded. If these are different, that's where you have to start. Make sure extension=imagick.so is in both ini files, also - verify that they are loading extensions from the same directory (99% chance they will be, but who knows - you could be an exception).

After you've verified that (possibly) both php.ini files are loading imagick.so and it's still not working, try to tail -f /path/to/apache/error_log (assuming you're using apache, of course..) and restart apache. You're looking here for php warnings about loading libraries and/or extensions. Hopefully it will point you in the right direction.

Hope this helps,

Jim

清音悠歌 2024-08-01 11:29:34

我最终做了什么:

将图像的方向存储在数据库中,然后使用 alternatiff 将图像动态旋转到存储的方向。 无需图像处理。

不过还是谢谢你的帮助。

What I ended up doing:

Storing the orientation of the image in the DB and then using alternatiff to dynamically rotate the image to the orientation that was stored. No image manipulation needed.

Thanks for your help though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文