Check if PHP exec() is Working on Your Ubuntu 14.04 LAMP Server

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

See more: ,

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]