I just was able to fix this.Actually php exec('whoami') was working but the httpd command was not. So after allowing apache to run commands with visudo and then ##Defaults requir... [by hercent]
on 01/12/2013 – Made popular on 01/12/2013
I am not able to run any sudo command in any exec call from php script if the php was execute from the browser. However if the same scripts runs under bash shell, it works just fine. I suspect there is some setting on apache to control this. Please kindly help!