[英]PHP exec() function to PING is not working for Cpanel
我创建了一个应用程序来监视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之上构建您的应用程序
首先检查,exec功能已被您的托管服务提供商禁用,或者未使用给定功能禁用。 此功能将列出您的主机提供商禁用的所有功能。
function disabled_functions(){ $disabled = explode(',', ini_get('disable_functions')); return $disabled; } echo '<pre>'; print_r(disabled_functions());
如果上面的disabled_functions()的输出中存在exec,那么您必须咨询您的主机提供商以允许shell访问和exec。 通常,由于安全问题,托管提供程序会禁用外壳程序访问和类似于exec的功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.