This solution seems not to work. I don't know why since I havent used SetUID with shell scripts. But I let this answer stay here just in case someone wants to refer to it.
For security reason I would recommand you to put your code into a bash file. Use the SetUID-bit to execute the bash file as root from within any other user. This way your file is not writeable by anyone else than root and you don't need to handle with sudo. Otherwise you allow your php-process to execute code as root which, in most cases, is a very bad idea.
The reason why you don't receive any output is probably because it ask for a password an there is no way for exec to enter one.
Edit:
Change your php call to:
<?
exec("/var/www/MountTheDisk.sh");
?>
Than create a bash file (/var/www/MountTheDisk.sh) with some content like this
#!/bin/sh
// this script will be executed as root
diskutil mount /dev/xvdb1 /mnt/theDisk/
echo trying to mount
Now set SetUID bit and change owner to root. (musst be done via root shell)
// make script executable
chmod +x /var/www/MountTheDisk.sh
// setuid bit
chmod u+s /var/www/MountTheDisk.sh
// change owner to root
chown root:root /var/www/MountTheDisk.sh
Note: Any user can run this file. Any call will result in it beeing executed as root.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…