Command-line installation composer
https://getcomposer.org/download/

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Globally Composer

mv composer.phar /usr/local/bin/composer

ubuntu18.04 apt-get install composer 

更换源,

composer config -g repo.packagist composer https://packagist.phpcomposer.com

 

Download drupal 

Option A: drupal-composer/drupal-project

  • Run composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --stability dev --no-interaction
  • This will download the 'drupal-composer/drupal-project' project into a folder named 'my_site_name_dir'
  • It also automatically executes composer install which will download Drupal 8 and all its dependencies. 

You might want to modify some of the properties of the downloaded composer.json before running composer install. For example, it is possible that you want to rename the subdirectory 'web' to something else.

  • Run git clone https://github.com/drupal-composer/drupal-project.git my_site_name_dir
  • You can go to my_site_name_dir and edit the composer.json file.
  • Run composer install. This will download Drupal 8 and all its dependencies. 

Follow the instructions for drupal-composer/drupal-project to learn more about it's configuration and features.

摘录
计算机