Add this entry in the sudoers file
username ALL=(ALL) NOPASSWD: /etc/init.d/Servicename *
If you are using php_exec,
apache ALL=(ALL) NOPASSWD: /etc/init.d/servicename *
Apache is the user who runs the webserver. It is www-data in some OS.
Also dont forgot to comment out
#Defaults requiretty
in sudoers file.