我创建了一个应用程序来监控 Network IP
或 Server Status
.它适用于 Windows xampp server
并且还在 linux centos 6.0
上进行了测试.两者都工作得很好。但是当我将脚本上传到安装了 cpanel 的网站并且我的脚本在那里不起作用时。那是一个linux托管服务器
我的 Windows Ping 命令:
$exec = exec( "ping www.google.com -n 3 ". $output, $status );
我的 Centos ping 命令:
$exec = exec( "ping www.google.com -c 3 ". $output, $status );
两个
$output
和 $status
变量返回准确的值。但是在 cpanel $output
为空白且 $status
变量返回 2 而不是 0 或 1需要帮忙
谢谢,
最佳答案
如果是,请检查您的主机提供商是否允许使用此功能,所以
尝试像这样使用 exec:$exec = exec( "ping www.google.com -c 3 ", $output, $status );
如果它不起作用,您可以尝试另一个 php 函数,如 exec:system('ping www.google.com -c 3 ', $output);
您可以使用 nagios 进行监控,并在 nagios 之上构建您的应用程序
关于PING的PHP exec()函数不适用于Cpanel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26558968/