Where is php ?

A question came up on the phpwomen channel today about how to find the path to php executable for use in cron scripts. The answer that came back very quickly to use which or whereis.

It turns out that the server in question is a shared host with a control panel for access to cron and ftp to upload your files. A test proved that shell_exec() wasn't going to work too. After discussing it for a little while and trying a few combinations, we came up with putting:

echo `whereis php` > DIR/whereisphp.txt

into the cron script control panel and set it to run in 2 minutes time. Then it was just a case of looking in the file and discovering that the php binary was in /usr/local/bin.

And this post is here to save me a little bit of time when no doubt I'll run into the same problem in a year's time...

3 Responses to “Where is php ?”

  1. 1 Nico

    As long as it's in you environment you can use '/usr/bin/env php', i.e. in you shebang line.

  2. 2 Rob...

    That's useful to know.

    Thanks Nico!

    Regards,

    Rob...

  3. 3 bob

    thanks for publishing this :)

The views expressed in these comments are not the views of the publisher. However, we believe in the rights of others to express their legitimate views and concerns. Any legitimate complaint emailed to rob@akrabat.com will be seriously considered and the post reviewed as desirable and necessary.