Imagick 安装错误 - 类未定义
好的,以下是具体情况的详细信息:
从命令行运行时没有错误(例如 sudo php myscript.php
- 但是,当通过网络浏览器运行时,我收到
致命错误:在 /var 中找不到类 'Imagick'第 1 行的 /www/lhackwith_www/test_html/magic.php
- 未安装
- extension=imagick.so 位于 imagick.ini 中,根据 phpInfo() 已成功读取该文件,
- 但是 imagick 未显示; PHP 信息中的
任何建议将不胜感激。
Okay, Here's a breakdown of what's up:
<? $foo = new Imagick(); ?>
works without error when ran from the command-line (e.g., sudo php myscript.php- 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
. - magickwand is not installed
- extension=imagick.so is in imagick.ini which is successfully being read according to phpInfo();
- However, imagick is NOT showing up in PHP info.
Any advice would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将 ubuntu 从 12.04 升级到 12.10 后,我在 imagick 上遇到了类似的问题。
经过一番摆弄,我最终发现需要一个不同的包(对于 php5?)并修复它:
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:
我认为您绝对确定您已经编辑了正确的 php.ini...
您是否检查了网络服务器的 error.log 以获得提示? 您可能想要增加该测试的 LogLevel。 如果是 apache,请参阅 http://httpd.apache.org/docs /2.2/mod/core.html#loglevel 和 http:// /httpd.apache.org/docs/2.2/logs.html#errorlog
或ldd - 打印共享库依赖项 可以阐明这个问题:
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
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:
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
您使用什么操作系统? 我在 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
我最终做了什么:
将图像的方向存储在数据库中,然后使用 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.