时间:2021-07-01 10:21:17 帮助过:12人阅读
系统:CentOS 6.3
apache是php的执行用户
用exec函数去执行linux系统上的程序/usr/local/yourcmd/sbin/yourcmd
php代码如下:
代码如下:
<?php
$conf_file = "/var/www/html/webroot/test.tmp";
$command = "sudo /usr/local/yourcmd/sbin/yourcmd -t -f {$conf_file}";
exec($command,$out);
print_r($out);
代码如下:
Array ( [0] => sudo: no tty present and no askpass program specified )
代码如下:
$ visudo
代码如下:
#Defaults requiretty
代码如下:
apache ALL=(ALL) NOPASSWD: ALL
Cmnd_Alias yourcmd = /usr/local/yourcmd/sbin/yourcmd
代码如下:
Array ( [0] => Warning: memory is too small: 1044725760 [1] => test configure is ok )