PHP 命令,未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43009623/
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
PHP Command, not found
提问by Nati V
I tried to install composer
via PHP command like said in getcomposer site,
But the bash throw an error:
我尝试composer
通过 PHP 命令安装,如 getcomposer 站点中所述,
但 bash 抛出错误:
bash: php: command not found
So I did a search in google , and I came up with some answers,
1) to add php binary file path to $PATH
variable
The problem is when I run:
所以我在 google 中进行了搜索,并得出了一些答案,1)将 php 二进制文件路径添加到$PATH
变量
问题是当我运行时:
find / -name php -type f
I get this error:
我收到此错误:
find: ‘/run/user/1000/gvfs': Permission denied
Even with sudo and as a root
即使使用 sudo 并作为 root
2) To install tht php-cli package, so I run
2) 要安装 php-cli 包,所以我运行
pacman -S php7-cli
But I get this error:
但我收到此错误:
error: target not found: php7-cli
So what it isn't working for me?
那么什么对我不起作用?
I installed php via XAMPP installer and I', using manjaro
我通过 XAMPP 安装程序安装了 php,我使用 manjaro
回答by fedeisas
Whenever you install XAMPP, you get all of the Apache, MySQL, PHP stack. The problem is, XAMPP won't link binaries to your PATH, because your could have another version of that software already installed.
无论何时安装 XAMPP,您都会获得所有 Apache、MySQL、PHP 堆栈。问题是,XAMPP 不会将二进制文件链接到您的 PATH,因为您可能已经安装了该软件的另一个版本。
Composer needs a PHP version available on your PATH, so the easier option is to link your already installed version of PHP.
Composer 需要在您的 PATH 上有可用的 PHP 版本,因此更简单的选择是链接您已安装的 PHP 版本。
I think you can find your PHP binary in /opt/lamp/bin
so you can link it this way:
我认为您可以在其中找到您的 PHP 二进制文件,/opt/lamp/bin
以便您可以通过以下方式链接它:
sudo ln -s /opt/llamp/bin/php /usr/bin/php
sudo ln -s /opt/llamp/bin/php /usr/bin/php
Hope it works!
希望它有效!
If you want to double check your PHP binary location you can go to files then at the end you can find "other locations" click it and then go and check it.
如果您想仔细检查您的 PHP 二进制位置,您可以转到文件,然后在最后您可以找到“其他位置”,单击它然后去检查它。
回答by transient_loop
You may be mixing up linux distributions.
您可能混淆了 linux 发行版。
php-cli is, I believe from debian-based distributions.
php-cli 是,我相信来自基于 debian 的发行版。
If you are using manjaro, check this wiki page for how to install php:
如果您使用的是 manjaro,请查看此 wiki 页面以了解如何安装 php:
https://wiki.archlinux.org/index.php/PHP
https://wiki.archlinux.org/index.php/PHP
Note that arch linux and manjaro are rolling releases, so it will install php7. Many things you find on the web are for lower versions, so be careful!
请注意,arch linux 和 manjaro 是滚动版本,因此它将安装 php7。你在网上找到的很多东西都是低版本的,所以要小心!