192:~ biancalouisedairo$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
192:~ biancalouisedairo$ php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
192:~ biancalouisedairo$ php composer-setup.php --install-dir=/usr/local/bin
All settings correct for using Composer
The installation directory "/usr/local/bin" is not writable
192:~ biancalouisedairo$
答案 0 :(得分:0)
这将删除任何已安装的Composer并为您正确安装:
sudo rm -f /usr/local/bin/composer
EXPECTED_SIGNATURE=$(curl -s https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" == "$ACTUAL_SIGNATURE" ]
then
php composer-setup.php --quiet
rm composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod 777 /usr/local/bin/composer
fi
答案 1 :(得分:0)
在命令前使用 sudo
像sudo php composer-setup.php --install-dir=/usr/local/bin
答案 2 :(得分:-2)
因为您不是root用户 使用sudo -i给出p