我有下面的PHP脚本 -从PHP脚本运行webkit2png工作在终端,而不是在浏览器
<?php
$command = "python webkit2png/webkit2png -D screenshots http://stackoverflow.com";
$command = escapeshellcmd($command);
system($command);
当从终端通过
php test.php
方式运行它产生的网站截图但是,在浏览器中打开test.php并不会带来任何结果。
python和php脚本都属于_www用户,在其下运行apache。我甚至尝试在终端下的_www下运行test.php,它仍然有效。有什么我失踪?
感谢@amccausl我发现这在Apache日志 -
Wed Feb 27 07:12:03 mini.local python[83331] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
Traceback (most recent call last):
File "webkit2png/webkit2png", line 353, in <module>
if __name__ == '__main__' : main()
File "webkit2png/webkit2png", line 324, in main
AppKit.NSBorderlessWindowMask, 2, 0)
objc.error: NSInternalInconsistencyException - Error (1002) creating CGSWindow
您应该检查您的apache错误日志。但是你也可以尝试在你自己的盒子中运行命令行(以隔离任何试图渲染webkit时没有连接终端的问题)。 – amccausl 2013-02-27 03:26:48