dongliqian6245 2014-03-05 01:02
浏览 33
已采纳

php cli和bashrc文件?

I am working on php terminal emulator, and it works, but its not using any .bashrc or .bash_profile files. So aliases to commands dont work. Im on a shared server which has both php5.4 and php 5.2 so when i run a command from the terminal emulator its using the wrong php version but if i actually ssh in and run commands its using the right version. I need to use php 5.4 but im not sure how to make that happen.

ive made sure that im acutally using bash

/bin/sh -> /bin/bash

here is my working (via ssh) .bashrc

alias 'php=/usr/local/php54/bin/php'
export PATH=~/bin/:/usr/local/php54/bin/:$PATH

however when i log in to my terminal emulator, echo $PATH produces

/usr/local/bin:/usr/bin:/bin

Im using system() to emulate, but i have also tried exec() and shell_exec

  • 写回答

2条回答 默认 最新

  • du532861657 2014-03-05 01:29
    关注

    If your problem is just with PHP (and you do not care about actually reading the .bash_profile file), then you can just call the PHP binary using the full path:

    $ /path/to/php somefile.php
    

    To determine which is the path of the "php" binary that you're executing when you're using SSH, just run:

    $ which php
    

    Will produce as output the full path (presumably "/usr/local/php54/bin/php")

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决