I have a user brftv on my linux system and I have www-data that runs the nginx.
from the terminal I can let my brftv user run
sudo /sbin/reboot
Try this code
brftv ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff www-data ALL=(brftv) NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff
then from php
exec('sudo /sbin/reboot');