To check if the PHP exec() function is working on your local LAMP server, paste this in the terminal:
echo "<?php echo 'whoim = '.exec('/usr/bin/whoami');?>" | sudo tee /var/www/html/whomi.php
Then, navigate in your browser to your http://localhost/whomi.php. You should see “whoim = ” and the user who executed the script. If you see this, then the PHP exec() function is working.
If you don’t see that, it doesn’t automatically mean that PHP exec is not working. There could be other problems. You’ll have to troubleshoot.
When you’re done testing, delete the whomi.php file by typing this in the terminal:
sudo rm /var/www/html/whomi.php