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条)

报告相同问题?

悬赏问题

  • ¥35 基于python的有ssl加密传输的socket聊天室
  • ¥15 数码管亮度控制器设计
  • ¥15 kafka客户端跨网段访问,看日志提示连接的还剩内网地址,且访问不通
  • ¥15 关于c语言代码的问题
  • ¥15 c51单片机控制步进电机
  • ¥20 Visual studio无法检测到设备
  • ¥30 vue 页面窗口放大或者缩小元素会变化
  • ¥15 questasim仿真报错
  • ¥15 寻找电脑攻防的导师,有问题请教一下。
  • ¥20 微信同是win11,我的电脑安装不了pageoffice,一直无法打开