Page 1 of 1

how do I exectute shell commands from a php script?

Posted: Tue Apr 25, 2006 8:21 pm
by tarzen5001
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.

Solved!!!

Posted: Tue Apr 25, 2006 9:54 pm
by tarzen5001
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.