问题描述
我刚刚在Cpanel中安装了Graphviz PEAR软件包,并尝试运行以下脚本:(来自 http://pear.php.net/manual/zh-CN/package.images.image-graphviz.example.php )
I just installed the Graphviz PEAR package in Cpanel and tried running the following script:(from http://pear.php.net/manual/en/package.images.image-graphviz.example.php )
[?php
require_once '/home/user_directory/php/Image/GraphViz.php';
$gv = new Image_GraphViz();
$gv->addEdge(array('wake up' => 'visit bathroom'));
$gv->addEdge(array('visit bathroom' => 'make coffee'));
$gv->image();
?]
如果运行此脚本,则会收到以下错误消息:
If I run this script I get the following error message:
Warning: fopen(/tmp/graph_8xynSO.svg) [function.fopen]:
failed to open stream: No such file or directory in
/home/user_directory/php/Image/GraphViz.php on line 210
我检查了/tmp目录上的权限:它们被设置为777(尽管在那里我看不到graph_8xynSO.svg文件).请问还有其他地方吗?
I checked the permissions on the /tmp directory: they're set to 777 (though I can't see the graph_8xynSO.svg file in there). Is there anywhere else I should be looking please?
谢谢
PHP
推荐答案
很有可能没有在主机上安装graphviz程序.您是否具有exec()功能或Shell访问权限?如果是这样,请尝试通过类似以下命令直接调用graphviz:
It's quite possible the graphviz program isn't installed on your host. Do you have exec() capability, or shell access? If so, try to invoke graphviz directly via a command like:
echo "digraph G {Hello->World}" | dot -Tpng >hello.png
Pear软件包将不包含graphviz程序,而仅仅是它的包装器.我不确定cPanel是否先进行依赖检查.如果这不是您的要求,则可能必须让管理员先安装graphviz.
The Pear package won't include the graphviz program, but is just a wrapper for it. I'm not sure if cPanel does the dependency check first. If it's not your box, you may have to get the admin to install graphviz first.
如果无法使graphviz在共享主机上工作,则可以调出Web服务来渲染图像.有关示例,请参见 http://bloodgate.com/graph-demo .
If you can't get graphviz to work on your shared host, you may be able to call out to a web service to render the image. See http://bloodgate.com/graph-demo for an example.
这篇关于Graphviz-临时图像无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!