Ponting Ponting - 4 months ago 6x
PHP Question

How to get path of the php binary on server where it is located

I am using exec command as below in PHP :

exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");

In local environment(MAMP),I know the php installation path so I can replace
. But I dont know where php installation(php binary) is located on production server?


It's usually /usr/bin/php but you could try to capture and parse the output of the command 'whereis php'.

Or better yet, use the constant PHP_BINARY. Have a look here.