If you do decide to host this script with root privileges, then you should (and I'm sorry) be locked up in a padded cell. That's just mad! You don't need root privileges to run a simple whois
command. That's insane!
Hosting as root is about as safe as a nursery, ran by catholic priests, serial killers and crack addicts, who haven't had a fix in three days. Things are going to happen... You can only speculate as to when and how bad it's going to end.
Check using whoami
what user is running the script, then check what it's PATH
looks like, compare that to where whois
actually is, if at all present. If it's not installed, ask your admin to set it up, and give you the rights to use it. If it's installed, try shel_exec('/path/to/bin/whois example.com');
Read up on user rights, and environment variables, (and how to load/manipulate them from a PHP script)