簡體   English   中英

Composer 已安裝,但得到 /usr/bin/env: php: No such file or directory

[英]Composer installed, but get /usr/bin/env: php: No such file or directory

在 CentOS 7 上,我安裝了 PHP 7.1。

然后我安裝了作曲家:

cd /tmp
curl -sS https://getcomposer.org/installer | php71     --> used php71 instead of php, php didn't work
mv composer.phar /usr/local/bin/composer

然后,在使用composer時,我得到:

/usr/bin/env: php: No such file or directory

使用sudo composer時,我得到:

sudo: composer: command not found

正如@alexhowansky建議的那樣,我運行了以下命令:

sudo ln -s /usr/bin/php71 /usr/bin/php

現在composer命令工作。 謝謝

您需要將/usr/local/bin添加到PATH變量中。 最簡單的方法是將它放在您的配置文件或位於以下任一位置的bash_profile中:

  • 〜/ .profile文件
  • 在〜/ .bash_profile

您可以將以下內容添加到其中一個文件中:

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

有關更多詳細信息,請參閱: https//unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path

如果您在添加時已登錄,則可以強制Linux再次讀取該文件並使用bash提示符中的source更新路徑(一旦進行了更改):

source ~/.bash_profile

至於php7php問題,正如Alex建議的那樣,你可以創建一個符號鏈接,所以它的工作方式就像一個別名。

這對我有用[Centos 7 with php 7.1]:
yum安裝php71w-cli

您需要安裝cli包。

yum install php71u-cli是我需要為IUS php做的事情。

我需要安裝 PHP

brew install php

當您在本地安裝 composer 時會出現此問題。

要使其全局可執行,請在終端中運行以下命令,

sudo mv composer.phar /usr/bin/composer

我也有這個問題。 我通過將 php 添加到路徑來修復它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM