I know on most servers the path to php is /usr/bin/php or /usr/local/bin/php or something like that, however I was wondering, is there a simple way to find out precisely the path to php by running a script or similar? All answers appreciated.
php_info() will give you some info. Mine returns: include_path .:/usr/local/lib/php .:/usr/local/lib/php And other paths.
That command assumes you have shell access to the server and it is done from the command line. Log in and simply type 'which php'.
If you look at the Configure Command for php_info() you will see the prefix used to compile PHP. It will be something like: './configure' '--with-prefix=/usr/' '--exec-prefix=/usr/' Code (markup): The above indicates that the path to php is /usr/bin.
<?php echo exec("which php"); ?> (or you can use the phpinfo(); command as stated above) That will give you the path to PHP, then put something like this in cron */5 * * * * /path/to/php -q /htdocs/www/x.php > /dev/null replace /path/to/php with your php path, and /htdocs/www/x.php with the php script you wish to run. remove the > /dev/null if you want the script output emailed to you. S.