今天發現/usr/bin/php與/usr/local/php/bin/php版本不同,以前明明還好好的……php
後面發現是 apt-get install composer默認安裝了一個php到/usr/bin/php把以前的PHP版本覆蓋掉了……php7
# php -v PHP 7.2.40 ...... #/usr/local/php/bin/php -v PHP 7.2.19 (cli) (built: Jul 3 2019 02:01:24) ( ZTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
參照度娘,修改composer 的PHP版本,發現仍是不行……composer
qing@qing-PC:~/Desktop$ composer PHP Warning: require(Composer/autoload.php): failed to open stream: No such file or directory in /usr/bin/composer on line 9 <span style='color: #ff0000'> Warning: require(Composer/autoload.php): failed to open stream: No such file or directory in /usr/bin/composer on line 9 </span>PHP Fatal error: require(): Failed opening required 'Composer/autoload.php' (include_path='.:/usr/local/php/lib/php') in /usr/bin/composer on line 9 <span style='color: #ff0000'> Fatal error: require(): Failed opening required 'Composer/autoload.php' (include_path='.:/usr/local/php/lib/php') in /usr/bin/composer on line 9
/usr/local/php/lib/php 目錄下根本找不到 'Composer/autoload.php' 文件……ui
無奈只能卸載composer,刪除composer自動安裝裝的php版本,刪除phar等composer相關文件 :spa
# apt-get remove composer # rm -rf /usr/bin/php # rm -rf /usr/bin/php7.2 # rm -rf /usr/bin/phar*
仍是經過官方的方式安裝composer吧……3d
# ln -s /usr/local/php/bin/php /usr/bin/php # wget https://getcomposer.org/installer # mv installer composer-setup.php # php composer-setup.php --install-dir=/usr/bin/ --filename=composer # php /usr/bin/composer
查看/usr/bin/php版本是否仍是被覆蓋掉……code
# php -v
仍是經過軟鏈接建立的php版本(ln -s /usr/local/php/bin/php /usr/bin/php)blog
說明/usr/bin/php並無被覆蓋掉。rem
composer問題解決……get