今天发现/usr/bin/php与/usr/local/php/bin/php版本不一样,之前明明还好好的……
后面发现是 apt-get install composer默认安装了一个php到/usr/bin/php把之前的PHP版本覆盖掉了……
# 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版本,发现还是不行……
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' 文件……
无奈只能卸载composer,删除composer自动安装装的php版本,删除phar等composer相关文件 :
# apt-get remove composer
# rm -rf /usr/bin/php
# rm -rf /usr/bin/php7.2
# rm -rf /usr/bin/phar*
还是通过官方的方式安装composer吧……
# 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版本是否还是被覆盖掉……
# php -v
还是通过软连接创建的php版本(ln -s /usr/local/php/bin/php /usr/bin/php)
说明/usr/bin/php并没有被覆盖掉。
composer问题解决……