Use visudo so you don’t completely destroy your PC. (Visudo will tell you there are any errors before you save [mistakes will permanently lock you out of your own PC].
Enter the details below then save..
www-data ALL=(ALL) ALL
If you wish to be more specific and give this user passwordless sudo for particular commands use the format
www-data ALL=(ALL) NOPASSWD: /sbin/shutdown, NOPASSWD: /sbin/reboot