I have a PHP script that does the following:
$output = exec('sudo nginx -t 2>&1');
echo $output;
As expected, it returns the following due to using a sudo command:
sudo: no tty present and no askpass program specified
However, I am able to run PHP in the terminal php /var/www/html/script.php and it works without being prompted for a sudo password.
Someone has told me that I am running PHP as a root on my system, which is dangerous.
However, all I did was follow this tutorial - is it really that dangerous?
Also, if I use a Cron job to run the PHP script, it runs perfectly
I am using NGINX with Ubuntu 20.04 + PHP 7