简体   繁体   English

找不到PHP命令

[英]PHP Command, not found

I tried to install composer via PHP command like said in getcomposer site, 我尝试通过PHP命令安装composer ,就像在getcomposer站点中所说的那样,
But the bash throw an error: 但是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 所以我在谷歌搜索了一下,我想出了一些答案,1)将PHP二进制文件路径添加到$PATH变量
The problem is when I run: 问题是当我跑:

 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安装程序和我'使用manjaro安装了php

Whenever you install XAMPP, you get all of the Apache, MySQL, PHP stack. 无论何时安装XAMPP,您都可以获得所有Apache,MySQL,PHP堆栈。 The problem is, XAMPP won't link binaries to your PATH, because your could have another version of that software already installed. 问题是,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: 我想你可以在/opt/lamp/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二进制位置,你可以去文件,然后你可以找到“其他位置”点击它然后去检查它。

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. 请注意,arch linux和manjaro是滚动版本,所以它将安装php7。 Many things you find on the web are for lower versions, so be careful! 您在网上找到的许多东西都是较低版本的,所以要小心!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM