dongtang8678 2015-12-07 17:44
浏览 118

获取当前运行版本的PHP版本

I have just built 3 different versions of PHP from source on an Ubuntu server (alongside NGINX and MySQL 5.7). I am looking for a way to run php --ini for the currently running version. I know I have to add the location to the file PATH in .bashrc so I don't have to add the full path.

I have added this to my .bashrc which allows me to get the currently running PHP version, which then allows me to run the command:

# parallels@ubuntu:~$ ps aux | grep php
# root      6948  0.0  0.2 153724  4620 ?        Ss   16:48   0:00 php-fpm: master process (/opt/php-7.0.0/etc/php-fpm.conf)

PHP_VERSION=$(ps aux | grep -o php-[[:digit:]].[[:digit:]].[[:digit:]])
export PATH="/bin:/usr/bin:/opt/$PHP_VERSION/bin:/sbin"

It works, but I am a bash novice and I'm thinking their might be a different way to do it. Would I be correct?

  • 写回答

3条回答 默认 最新

  • douye1876 2016-12-10 00:12
    关注
    PHP_VERSION=$(php -v | tail -r | tail -n 1 | cut -d " " -f 2 | cut -c 1-3)
    cd /usr/local/etc/php/$PHP_VERSION/
    # cd /usr/local/etc/php/7.1/
    
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题