Im trying to execute a shell command from a php script.
the php script is in /var/www/kernel_web
#install.php
<?php
exec("sudo -u root /var/www/./test.sh");
?>
commands like ls works but anything with a sudo wouldnt work
i have already edited to etc/sudoers file so it wouldnt ask for password.
%admin ALL=(ALL) NOPASSWD:ALL
the error log on var/log/apache2/error.log reports that the command requires a password.
how do I exectute shell commands from a php script?
Moderator: General Moderators
-
tarzen5001
- Forum Newbie
- Posts: 2
- Joined: Tue Apr 25, 2006 8:01 pm
-
tarzen5001
- Forum Newbie
- Posts: 2
- Joined: Tue Apr 25, 2006 8:01 pm
Solved!!!
Basically I was forgetting that the group was NOT www but rather www-data, so the solution is to add to /etc/sudoers (use visudo) the line that allows the group www-data to not be prompted the password prompt with "%www-data ALL=(ALL) NOPASSWD:ALL" added to /etc/sudoers.