我在下載 Composer 時遇到此類錯誤。
php composer-setup.php
All settings correct for using Composer
PHP Warning: file_put_contents(/home/vasu/.composer/keys.dev.pub): failed to open stream: Permission denied in /home/vasu/composer-setup.php on line 468
PHP Warning: file_put_contents(/home/vasu/.composer/keys.tags.pub): failed to open stream: Permission denied in /home/vasu/composer-setup.php on line 485
Downloading 1.2.0...
PHP Warning: openssl_verify(): supplied key param cannot be coerced into a public key in /home/vasu/composer-setup.php on line 576
PHP Warning: openssl_free_key() expects parameter 1 to be resource, boolean given in /home/vasu/composer-setup.php on line 577
Signature mismatch, could not verify the phar file integrity
答案1
簡單的方法
首先嘗試簡單的方法。由於評論中提到的錯誤訊息,這個答案包含了困難的方法。
sudo mkdir -p /usr/local/bin
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
在 Ubuntu 16.04 及更高版本中,可以從預設的 Ubuntu 儲存庫安裝 Composer。打開終端機並輸入:
sudo apt install composer
艱辛的道路
首先檢查是否/usr/local/bin/
存在,如果不存在則建立該/usr/local/bin/
目錄。
sudo mkdir -p /usr/local/bin
如果/usr/local/bin/
已經存在,上面的命令除了返回此訊息之外不會執行任何操作:
mkdir: cannot create directory ‘/usr/local/bin’: File exists
運行這些命令:
sudo chmod -R 755 /usr/local/bin/
cd /usr/local/bin/
ls # list the old composer file(s)
sudo rm <old-composer-files> # delete the old composer file(s)
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
然後,如果您composer
在終端機中輸入,它將可以在您的系統中全域存取。