PHP: Finding the binary

The other day I was stumped, albeit rather briefly, by something I should not have been. I was scripting out some CRON jobs for a CRM system when I found out I could not locate where the hosting company had put the PHP binary. Now that is something you usually do not have to think about so it can easily fall into the ‘been a while’ category.

So if you ever find yourself asking, where is the PHP binary? or just where is PHP? Here are some steps to follow.

Telnet/Shell
If you have shell access via telnet, log in, and type “which php” and you should be given the location to use.

If you don’t have shell, try one of the following:

Create a php page with just the following: and then call the page, this should tell you the location of PHP.

echo system('which php');

If that does not work, though it should, try checking one of the paths listed under path in the ENVIRONMENT section of the output with this.Take note though that this will give you the environment path so you will still need to add /php to it…

echo phpinfo();