permission denied for composer in /usr/local/bin/

后端 未结 9 767
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 20:16

I followed the documentation on https://getcomposer.org/doc/00-intro.md#globally to install composer globally on arch linux. When I do composer self-update, I g

相关标签:
9条回答
  • 2020-12-30 20:47

    Use sudo command for any command which writes to root files of folder. It worked for me.

    use sudo "your command"

    0 讨论(0)
  • 2020-12-30 20:49

    Now, there is a package for composer in arch linux which works for me:

    sudo pacman -S composer
    
    0 讨论(0)
  • 2020-12-30 20:52

    On Ubuntu server >= 16.04

    FIRST

    sudo rm /usr/local/bin/composer
    

    AND

    cd ~/.cache/composer
    chmod 755 composer-temp.phar
    sudo mv composer-temp.phar /usr/local/bin/composer
    
    0 讨论(0)
  • 2020-12-30 20:56

    this might be the case if you have downloaded composer.phar directly ,

    but not by running php composer-setup.php

    make composer.phar executable with following command before moving it to /usr/local/bin/composer or after moving

    sudo chmod 755 composer.phar

    composer-setup.php will make this change for us by default

    0 讨论(0)
  • 2020-12-30 20:59

    You should check the permissions of the directory /usr/local/bin/, not just the file within. The process has to write both, the file and into the directory which both must be granted.

    Apart from that, a general hint: do not always set everything to 777. There is no reason for that and it makes your system vulnerable.

    According to the line you posted in the last comment the directory is currently writeable only for the root user himself. That would explain the error you get. You should not make your own user account the owner, Linux systems are multi user environments. Instead think about one of these approaches:

    • add the account that is meant to execute the composer to the group root (a user account can belong to several groups) and make the directory group writeable
    • change the groups ownership of the directory to a group that account is a member of and make the directory group writeable
    • use the sudo utility to install and update the composer utility

    The last option is the typically chosen and preferred one. It leaves permissions as they are (conservative) and only uses raised privileges for system maintenance jobs like installation and upgrade.

    0 讨论(0)
  • 2020-12-30 21:00

    make sure composer already at /usr/local/bin and then do following things

    chmod 755 composer
    

    if permission denied, add sudo

    0 讨论(0)
提交回复
热议问题