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

报告相同问题?

悬赏问题

  • ¥15 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?