Home > Backend Development > PHP Tutorial > 关于php使用system()开启linux下的firefox,报错:Error:no display specified,该如何处理

关于php使用system()开启linux下的firefox,报错:Error:no display specified,该如何处理

WBOY
Release: 2016-06-13 10:24:07
Original
1763 people have browsed it

关于php使用system()开启linux下的firefox,报错:Error:no display specified
求各位大侠帮助?

------解决方案--------------------
是否有操作权限?

代码呢?
------解决方案--------------------
浏览器访问和终端下的访问是两个权限。浏览器中是普通用户权限,你在机子上装sudo
#查询sudo版本
apt-cache search sudo
#安装sudo
apt-get install sudo
然后:system("sudo firefox http://www.baidu.com"); //切换至root权限

------解决方案--------------------

探讨

全部代码是这样的:
$cmd = "sudo firefox --saveimage http://baidu.com";
system($cmd,$str);
echo $str;
我想要实现的是开启firefox把整个网页保存成图片
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template