Ubuntu安装Composer, Ubuntu升级Composer, 升级Composer 1.x 到 2.x, How to Install and Use PHP Composer on Ubuntu 20.04

Ubuntu安装Composer, Ubuntu升级Composer, 升级Composer 1.x 到 2.x, How to Install and Use PHP Composer on Ubuntu 20.04
Ubuntu安装Composer, Ubuntu升级Composer, 升级Composer 1.x 到 2.x, How to Install and Use PHP Composer on Ubuntu 20.04

 

 

升级的方法很简单,就是先卸载后安装:

# you need to first remove the composer
sudo apt-get remove composer 

# ubuntu install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

# and then type the below command to install composer globally  
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

# When a new Composer version is available, you can update your installation using the following command:
sudo composer self-update  

 

其他方法参考:

update composer ubuntu  更新:

##update composer in ubuntu
#update packages
sudo apt-get update
#if you don't have curl install it
sudo apt-get install curl
#download installer
sudo curl -s https://getcomposer.org/installer | php
#move composer.phar file
sudo mv composer.phar /usr/local/bin/composer
#check composer version
composer -v

 

install composer on linux 安装

# The following method has been tested on Ubuntu 20.04
# But i think it should work fine with any other distribution

# Ensure you're on Desktop, to prevent issues with permissions
cd ~/Desktop

# Download the installer script
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

# Verify intergrity to check whether an error happened during the fetch
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

# Download composer script, which is the actual composer file
php composer-setup.php

# Remove the installer script as it's no longer needed
php -r "unlink('composer-setup.php');"

# To use composer globally, it's a good idea to move it to the path
# /usr/local/bin
sudo mv composer.phar /usr/local/bin/composer

# Try running composer to see if everything works fine
composer -V
# If you see the following output, then you're good to go:
# Composer version 1.10.10 2020-08-03 11:35:19

 

本文: Ubuntu安装Composer, Ubuntu升级Composer, 升级Composer 1.x 到 2.x, How to Install and Use PHP Composer on Ubuntu 20.04

Loading

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.