Let's take a look at how PHP does not have the permission to call Linux commands. I hope the article will help you. business Background: yourcmd is my linux program. it has strict permission requirements. when using php to execute yourcmd... let's take a look at how PHP does not have the permission to call Linux commands. I hope the article will help you.
Business background:Yourcmd is my linux program, which has strict permission requirements. when using php to execute yourcmd program
System:CentOS 1, 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 test result shows no permission.
Array ([0] => sudo: no tty present and no askpass program specified)
Solution:
$ Mongodo
1) comment out the following lines:
#Defaults requiretty
2) add the following to the end of the file:
apache ALL=(ALL) NOPASSWD: ALLCmnd_Alias yourcmd = /usr/local/yourcmd/sbin/yourcmd
Test result:
Array ( [0] => Warning: memory is too small: 1044725760 [1] => test configure is ok )
Article link:
Save this article for favorites!