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

半城伤御伤魂 提交于 2019-12-03 07:12:14

问题


On CentOS 7, I installed PHP 7.1.

Then I installed composer with:

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

Then, when using composer, I get:

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

When using sudo composer, I get:

sudo: composer: command not found

回答1:


As @alexhowansky suggested, I ran the following command:

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

Now the composer command works. Thanks




回答2:


You need to add /usr/local/bin to your PATH variable. The easiest way is to throw it in your profile or bash_profile located at either:

  • ~/.profile
  • ~/.bash_profile

You would add the following to one of those files:

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

For more details, see: https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path

If you are logged in when you add it, you can force Linux to read the file again and update the path (once the changes are made) by using source from the bash prompt:

source ~/.bash_profile

As for the php7 vs. php issue, as Alex suggested, you can make a symlink so it works kinda like an alias.




回答3:


This worked for me [Centos 7 with php 7.1] :
yum install php71w-cli




回答4:


You need to install the cli package.

yum install php71u-cli is what I needed to do for IUS php.



来源:https://stackoverflow.com/questions/43878731/composer-installed-but-get-usr-bin-env-php-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!