I am using the exec
command as below in PHP :
exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");
In my local environment (MAMP), I know the PHP installation path, so I can replace /usr/bin/php
with /Applications/MAMP/bin/php/php5.4.10/bin/php
. But I don't know where the PHP installation (PHP binary) is located on the production server.
It's usually /usr/bin/php
but you could try to capture and parse the output of the command 'whereis php
' or 'which php'
'.
Or better yet, use the constant PHP_BINARY
if it is available. Have a look here.