I have a script in /var/www/myscript.sh which creates folders and runs the command svn update
for my projects. I need to execute this script by calling it in a PHP file in the browser (i.e. Localhost/test.php). I tried using functions shell_exec()
and exec()
but those did not work. I ran my shell script in terminal with su www-data && ./myscript.sh
and it worked. What else am I missing?
<?php
$output = shell_exec("./myscript.sh");
?>
Update 5/4/2011:
I added www-data ALL=(ALL) NOPASSWD:ALL
to /etc/sudoers and it works, but this is very insecure. Is there another way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…