Most of the time, if a command works from the command prompt, but not from PHP's exec() (or shell_exec() command), it is because of one of the following:
1) A permissions problem. You have the permissions necessary to run the command as the user that you are executing the command as from the command line. But, the user that PHP is running as does not have necessary permissions.
2) An environment problem. An environment variable (such as a path) is defined in the environment of the user that you are executing the command as from the command line. But, this environment variable is not setup in the environment of the user that PHP is running as.