[英]php-fpm: shell_exec not working to execute some scripts
server: Debian 11, nginx, php8.1-fpm
服务器:Debian 11、nginx、php8.1-fpm
i want to execute this command from php but is not working, when i run from terminal (root)it works我想从 php 执行这个命令但不工作,当我从终端(root)运行时它工作
$output = shell_exec('/usr/bin/dos2unix /var/www/script.sh');
echo $output;
when i run the code below it works当我运行下面的代码时它可以工作
$output = shell_exec('ls /usr/bin/');
echo $output;
i think the user that run the script is www-data based on the code below我认为运行脚本的用户是www-data基于下面的代码
$linuxUser = posix_getpwuid(posix_getuid());
echo $linuxUser['name'];
result is www-data
also i added this in visudo just to test but still not working我也在visudo中添加了这个只是为了测试但仍然无法正常工作
www-data ALL=NOPASSWD: ALL
www-数据 ALL=NOPASSWD: ALL
in visudo when u paste this当您粘贴此内容时,在visudo中
www-data ALL=(ALL) NOPASSWD:ALL
make sure it is at the very bottom line or it will not work, so move that line at the end of the file确保它位于最底线,否则它将不起作用,因此将该行移到文件末尾
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.