Run PHP shell_exec as root
I am trying to get my php script to add a user using the shell_exec function and the shell function "useradd". I have tried this, which works from the shell
echo rootpass |sudo /usr/sbin/useradd -d /home/username -m -p userspassword username
This works from the shell, but doesn't work from the php script. I know basic shell_exec functions work, but this one needs to be executed as root, and I don't know what to do.
How can I fix this? Thanks