php 须藤:梨:找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6222975/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:41:52  来源:igfitidea点击:

sudo: pear: command not found

phpmacospear

提问by keeg

I have snow leopard which apparently has php with pear pre-installed. I enabled php but could not find any signs of PEAR. So I have installed it and now phpinfo() shows its installation

我有雪豹,它显然预装了带有梨的 php。我启用了 php 但找不到任何 PEAR 的迹象。所以我已经安装了它,现在 phpinfo() 显示了它的安装

include_path .:/usr/lib/php/share/pear

Still when I type in any pear command

仍然当我输入任何梨命令时

$ sudo pear

I get an error: sudo: pear: command not found

我收到一个错误:sudo: pear: command not found

What am I missing?

我错过了什么?

回答by Trott

Many ways to skin this cat, but I would type this if you have locate installed (which you probably do):

给这只猫剥皮的方法有很多,但如果你安装了 locate(你可能会这样做),我会输入这个:

$ locate bin/pear

That should list one or more things, one of which will look like the path to pear. Let's say it says something like /usr/local/bin/pear. Then your next command is:

这应该列出一项或多项内容,其中一项看起来像是通往梨的道路。假设它说的是类似的东西/usr/local/bin/pear。那么你的下一个命令是:

$ sudo /usr/local/bin/pear

Two caveats come to mind:

想到两个警告:

  1. It's possible that locate will list multiple executable pear files. If that's the case, it may be important to pick the right one based on which PHP you're using.
  2. You may want to add the directory where pearis located to your PATHenvironment variable.
  1. locate 可能会列出多个可执行的梨形文件。如果是这种情况,根据您使用的 PHP 选择正确的 PHP 可能很重要。
  2. 您可能希望将所在的目录添加pear到您的PATH环境变量中。

回答by David Lin

You need to update your system $PATH variable in order for the pear command to work. Edit the bash profile file using the following(if you have textmate):

您需要更新系统 $PATH 变量才能使 pear 命令工作。使用以下内容编辑 bash 配置文件(如果您有 textmate):

mate ~/.bash_profile

and add in this line:

并在这一行中添加:

export PATH=/usr/local/pear/bin:$PATH

reload your terminal after that and it should work now

之后重新加载您的终端,它现在应该可以工作了

Edited:Thanks for highlighting my mistake trott. I have changed the path to locate where the bin should roughly be(depending on where one chooses to install it)

编辑:感谢您强调我的错误 trott。我已经更改了路径以定位垃圾箱的大致位置(取决于选择安装它的位置)

回答by aurny2420289

If you have installed pear directly on PHP(MAMP, for example) you should copy pearto /usr/local/bin:

如果您直接在PHP( MAMP)上安装了 pear ,则应复制pear/usr/local/bin

cp /php5.3.2/pear /usr/local/bin/pear

then export var PATH, and test with "pear" in the shell.

然后导出 var PATH,并pear在 shell 中使用 " " 进行测试。

回答by codemonkee

I had a similar issue and required updating secure_path in sudoers as it overrides user's $PATH.

我有一个类似的问题,需要更新 sudoers 中的 secure_path,因为它覆盖了用户的 $PATH。

Check for secure_pathon sudo

检查sudo 上的secure_path

[root@host ~]# sudo -V | grep 'Value to override'
Value to override user's $PATH with: /sbin:/bin:/usr/sbin:/usr/bin

If $PATHis being overriden us visudoand edit /etc/sudoers

如果$PATH被我们覆盖visudo并编辑/etc/sudoers

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin