Basically I am trying to restart a service from a php web page.
Here is the code:
This is probably down to something like trying to execute sudo in a non-interactive shell.
If you do a grep for 'sudo' in your apache users mail log you might find things like this
sudo: sorry, you must have a tty to run sudo