Php 7 PHP wkhtmltoimage无法与shell_exec一起使用

Php 7 PHP wkhtmltoimage无法与shell_exec一起使用,php-7,wkhtmltoimage,Php 7,Wkhtmltoimage,我试着拍摄这样的截图: shell_exec("/usr/bin/wkhtmltoimage http://google.com screen.png"); 但它并没有创建screen.png。但是当我跑的时候 /usr/bin/wkhtmltimagehttp://google.com screen.png 从终端开始,它按预期工作。我不知道怎么了。 我试着像这样写日志: shell_exec("/usr/bin/wkhtmltoimage http://google.com screen.

我试着拍摄这样的截图:

shell_exec("/usr/bin/wkhtmltoimage http://google.com screen.png");
但它并没有创建screen.png。但是当我跑的时候
/usr/bin/wkhtmltimagehttp://google.com screen.png
从终端开始,它按预期工作。我不知道怎么了。 我试着像这样写日志:

shell_exec("/usr/bin/wkhtmltoimage http://google.com screen.png > debug.log 2>&1");
我收到日志“QXcbConnection:无法连接到显示器 debug.log上的“已中止(内核转储)”。我在Ubuntu上安装了带有Nginx的php7.0。
解决这个问题的办法是什么?如果有人解决了同样的问题,请分享

可能是访问权限。我在这里找到了解决方案:。但是只为pdf工作。当我创建png、jpg图像时,它只创建了一个空白图像。