Intervention imagick works in terminal but not in

2019-03-03 10:59发布

问题:

I quite don't understand what's going wrong. I've installed Intervention from as guided here

Then I created the following .php file and started my localhost Apache server and tested the results and it worked!

Here's the code:

test.php

<?php
require 'vendor/autoload.php';
use Intervention\Image\ImageManagerStatic as Image;
Image::configure(array('driver' => 'gd'));
$image = Image::make('ar.jpg');
$path = 'public/images/photoh.png';
$image->save($path);
?>

But when I run the same file using php test.php in Ubuntu terminal, I get the following error:

GD Library extension not available with this PHP installation.

When I checked the phpinfo(), I saw gd being listed there with version 2.1.0

This is not the real issue, but still I would like to know what can be wrong and how can I solve it.

Then comes the real problem. I installed Imagick separately using following command:

sudo apt-get install php-imagick

This installed Imagick 6.8 on my system (I checked this using convert -version)

Then I added following to php.ini file:

extension=imagick.so

And then for testing, I changed the driver to 'imagick' in test.php and executed it using php in terminal and it worked fine.

But I want it to work on browser, like GD, but IT DIDN'T.

It showed the similar error that GD showed on terminal:

ImageMagick module not available with this PHP installation.

So it seems like ImageMagick is installed but something is missing. Is there something I can do?

Ubuntu: 16.04 LTS PHP: 5.6

回答1:

Firstly, there are likely various php.ini files on your system. You can find the various files by typing locate php.ini in a terminal. Verify you're editing the intended version for the web. Secondly, I would restart your web service. If you're using apache you can type sudo service apache2 restart in a terminal to restart it.