PHP has insufficient permissions to call Linux commands. Solution: phplinux. PHP has insufficient permissions to call Linux commands. phplinux business background: yourcmd is my linux program. it has strict permission requirements. when using php to execute yourcmd program system: PHP has insufficient permissions to call Linux commands. Solution: phplinux
Business Background: yourcmd is my linux program, which has strict permission requirements. when using php to execute yourcmd program
System: CentOS 6.3
Apache is the execution user of php.
Execute the program/usr/local/yourcmd/sbin/yourcmd on linux using the exec function
The php code is as follows:
The code is as follows:
<? 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 );
The test result shows no permission.
The code is as follows:
Array ([0] => sudo: no tty present and no askpass program specified)
Solution:
The code is as follows:
$ Mongodo
1) comment out the following lines:
The code is as follows:
# Defaults requiretty
2) add the following to the end of the file:
The code is as follows:
Apache ALL = (ALL) NOPASSWD: ALL
Cmnd_Alias yourcmd =/usr/local/yourcmd/sbin/yourcmd
Test result
The code is as follows:
Array ([0] => Warning: memory is too small: 1044725760 [1] => test configure is OK)
Business background: yourcmd is my linux program. it has strict permission requirements. when using php to execute yourcmd program System :...