Imagick 功能可在一台服务器上运行但在另一台服务器上不起作用

Imagick function that works on one server and doesn't work on another

我在将我的脚本从一台服务器移动到另一台服务器时遇到问题。

PHP 脚本读取 PDF 文件并为 pdf 的每一页创建图像。 此脚本当前在具有这些特征的环境中工作

现在我已将脚本移动到具有这些特征的环境中:

密码是:

$img = new Imagick($percorsoBaseDir); //LINE OF THE ERROR
$img->setResolution(600, 600);
$num_pages = $img->getNumberImages();
$img->setImageCompressionQuality(100);
$images = NULL;
for ($i; $i < $num_pages; $i++)
{
   ..... [My script] ....
}

错误是:

AH01071: Got error 'PHP message: PHP Fatal error: Uncaught ImagickException: Failed to read the file in /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/custom_plugin/includes/woocommerce/Step_2.php:222\nStack trace:\n#0 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/custom_plugin/includes/woocommerce/Step_2.php(222): Imagick->readImage()\n#1 /var/www/vhosts/mysite.com/httpdocs/wp-includes/shortcodes.php(356): step_2_function()\n#2 [internal function]: do_shortcode_tag()\n#3 /var/www/vhosts/mysite.com/httpdocs/wp-includes/shortcodes.php(228): preg_replace_callback()\n#4 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/js_composer/include/helpers/helpers.php(247): do_shortcode()\n#5 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/js_composer/include/templates/shortcodes/vc_column_text.php(31): wpb_js_remove_wpautop()\n#6 /var/www/vhosts/mysite.com/httpdocs/wp-content/plugins/js_composer/include/classes/shortcodes/core/class-wpbakeryshortcode.php(451): require('/var/www/...', 

我也试过扔:

getcwd() //to verify that the file exists

和:

is_readable ($ pathBaseDir) //to verify that the file exist and is readable
is_writable ($ pathBaseDir) //to verify that the file exist and is writable

他们都 return 正确。

我还检查了文件是否正确加载到文件系统中,并且我可以从浏览器中打开它。

我不明白这可能是什么错误,你也遇到过类似的事情吗?我该如何解决?

谢谢!

我发现了问题:我已经使用以下命令在我的服务器中安装了 Ghost 脚本:

apt-get install ghostscript 

现在可以使用了!