I tested my website on my development machine fine, but have an error below when being deployed on a shared server:
2015-10-27 08:00:10 [109.147.72.104][-][2d12367f735ce12cdfeba82a431366ad][error][yii\base\ErrorException:32] exception ‘yii\base\ErrorException’ with message ‘PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20100525/imagick.so’ - libMagickWand.so.2: cannot open shared object file: No such file or directory’ in Unknown:0
I ran the requirements.php and it passed, the server side support engineer also confirmed that imagick.so exists in the path shown above.
The engineer is struggling to identify the problem.
Does anyone had similar probelm before?
This error occurs on every page of my website, eventhough most pages are not Captcha.
The pages are rendered, and then at the bottom of the page this error turns up.
Could anyone point to me the code that is causing this error? It seems to be the yii2 core, but why on pages that do not use Captcha still get this error?
Also is there a way in YII2 to ask Captcha to try using GD first instead Imagick? I am asking this because my gut feeling is the Imagick extension has problem.
I don’t know if its the best solution, but to force GD you can extend \yii\captcha\CaptchaAction class and override renderImage () method. Something like this:
<?php
namespace app\components;
class CaptchaAction extends \yii\captcha\CaptchaAction
{
protected function renderImage($code)
{
return $this->renderImageByGD($code);
}
}
Thanks for the solution, I will try and see if it works.
What puzzles me is that even pages not using Captcha get this error (actually on every page), so it seems to me a code down in Yii2 core is trying to use Imagick but failed (not only load the extension, because the requirements.php ran successfully, which does load Imagick).
Unfortunately I am not an expert in Yii2, and can’t get much info from the stack trace.
It seems to be an Imagick installation problem. Yii2 core doesn’t use Imagick.
Take a look at this thread. Maybe it isn’t the solution for your case but is the same problem.
You don’t see the same error on requirements.php because it not loads Yii2, so the framework error handler is not set and this warning is not shown. But probably appears in php error log.