问题
$im = new imagick($file);
This line of code will work fine when ran from my browser, but when I try to run it from command line (CLI) then I get the following error...
Class 'imagick' not found
Any ideas why it won't work from CLI?
回答1:
Found a solution:
sudo aptitude install make php5-dev php-pear
sudo aptitude remove php5-imagick
sudo aptitude install libmagick9-dev
sudo pecl install imagick
sudo /etc/init.d/apache2 restart
http://kvz.io/blog/2008/02/27/class-imagick-not-found/
回答2:
The php cli executable is seperate(as in, a seperate binary file) from what generally gets run through a webserver. So, they can be totally different php versions, with different php.ini files and different extensions compiled in/enabled.
回答3:
Run "php -i | grep include_path" and make sure that class file path is in there. If not, you can either add it in your script or your environment (bash profile).
来源:https://stackoverflow.com/questions/10624582/class-imagick-not-found-when-ran-from-cli