Ubuntu: Sh: php command not found when trying to execute file from web broeser



Question:

I have one file with code

shell_exec (php test.php)  

When I run this file from command prompt, It run successfully and when same file I am trying to run through web browser this will give error as

sh: php command not found.  

what can be the issue?


Solution:1

Most likely the path for php isn't in the $PATH environment variable used for shell_exec when you are running it from the web server.

Use the full path for the php command, like

shell_exec (/usr/bin/php test.php)  

You can use the which command on the command prompt to find the full path for php

which php  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »