dosin84644 2011-04-21 18:18
浏览 48
已采纳

如何在OSX上为用户.bash_profile设置系统$ PATH以获取您安装的已添加的PHP版本

Ok so here is my problem. I am trying to write a php script that will run the following type of command.

exec("$(which php) -f /path/to/script.php >> /path/to/log.log 2>&1 &");

The problem is, I am running OSX 10.5 leopard and using the Entropy PHP package. This creates php under /usr/local/php5/bin. The normal php that is installed with OSX in under /usr/bin. So when PHP executes this command it is using the wrong PHP executable. Now I know how to change the $PATH in my .bash_profile by adding it to the begining of the $PATH so that the system takes the PHP I want other then the default PHP. The problem is, when running the php from a script it doesn't do it under my user. So then it doesn't have the updated $PATH settings.

I have also looked into setting it in /etc/paths and etc/paths.d/ but these both append the path to the end, I need it to append to the beginning so that my script will use the right PHP executable.

I know I probably could run another exec command and set the path but this is only a local environment issue and when the code goes to production I won't need this set.

  • 写回答

3条回答 默认 最新

  • duanpen9294 2011-04-21 18:25
    关注

    One option is to set the global path for all users. See this answer for a few examples.

    For example, if the user running the command is using bash as its shell you may edit /etc/bashrc adding a line like:

    export PATH="$PATH:/more/paths:/
    

    Another option is to modify /etc/launchd.conf (note that it does not exist on Leopard by default and expects csh setenv syntax)

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

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?