- wget http://www.graphviz.org/graphviz-rhel.repo /etc/yum.repos.d/graphviz-rhel.repo
- yum install graphviz
2.安装完毕后进行测试
- echo “digraph G {Hello->World}” | dot -Tpng >hello.png
3.php 调用graphviz 首先用程序生成/tmp/domain.txt,然后用dot命令生成图片
- <?php
- header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
- header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
- header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
- header ("Pragma: no-cache"); // HTTP/1.0
- header ("Content-type: p_w_picpath/gif");
- $filename = '/tmp/domain.txt';
- $somecontent = "digraph G {a->b->c->a}";
- if (!$handle = fopen($filename, 'w')) {
- echo "cannot open $filename";
- exit;
- }
- if (fwrite($handle, $somecontent) === FALSE) {
- echo "cannot write to $filename";
- exit;
- }
- fclose($handle);
- passthru("dot -Tpng $filename");
- // passthru("cat $filename | dot -Tpng");
- ?>
end