如何获取PHP二进制文件所在的服务器上的路径 [英] How to get path of the php binary on server where it is located

查看:329
本文介绍了如何获取PHP二进制文件所在的服务器上的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在如下PHP中使用exec命令:

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 &");

在我的本地环境(MAMP)中,我知道PHP的安装路径,因此可以将/usr/bin/php替换为/Applications/MAMP/bin/php/php5.4.10/bin/php.但是我不知道PHP安装(PHP二进制文件)在生产服务器上的位置.

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.

推荐答案

通常为/usr/bin/php,但是您可以尝试捕获并解析命令'whereis php'或'which php''的输出.

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

或者更好的是,使用常量PHP_BINARY(如果可用).在此处.

Or better yet, use the constant PHP_BINARY if it is available. Have a look here.

这篇关于如何获取PHP二进制文件所在的服务器上的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆