I want to run a "sudo" command from the PHP and I have read all the tutorials on the web, but no solution works. At least I've added the default "nobody" user of LAMP to the root group – but no effect.
echo exec("sudo echo hi");
A note on security:
While some people here are downvoting this due to their strong belief that this will create a big security hole that will destroy the entire Internet, there are some valid cases for this, e.g., in testing. Running setup scripts from PHPUnit / Behat suites to configure the environment may require sudo permission. Those scripts are not accessible from the application and do not create security holes, as the matter of fact they help to ensure such holes are not present.