Report this

What is the reason for this report?

Guía de inicio [rápido sobre Cómo instalar Composer en Ubuntu 20.04]

Published on June 11, 2020
Erika Heidi

By Erika Heidi

Developer Advocate

Español
Guía de inicio [rápido sobre Cómo instalar Composer en Ubuntu 20.04]

Introducción

En esta guía de inicio rápido, instalaremos Composer en un servidor de Ubuntu 20.04.

Para obtener una versión más detallada de este tutorial, con más explicaciones de cada paso, consulte Cómo instalar y utilizar Composer en Ubuntu 20.04.

Requisitos previos

Para completar esta guía, necesitará acceso a un servidor de Ubuntu 20.04 como usuario sudo.

Paso 1: Instalar las dependencias

Comience actualizando el caché de su administrador de paquetes e instalando las dependencias requeridas, incluyendo php-cli:

  1. sudo apt update
  2. sudo apt install php-cli unzip

Paso 2: Descargar e instalar Composer

Asegúrese de posicionarse en su directorio de inicio y obtenga el instalador de Composer usando curl:

  1. cd ~
  2. curl -sS https://getcomposer.org/installer -o composer-setup.php

A continuación, verificaremos que el instalador descargado coincida con el hash SHA-384 para el instalador más reciente disponible en la página Composer Public Keys/Signatures.

Usando curl, busque la última firma y guárdela en una variable shell:

  1. HASH=`curl -sS https://composer.github.io/installer.sig`

Ahora, ejecute el siguiente código PHP para verificar que la secuencia de comandos de instalación es segura:

  1. php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Verá el siguiente resultado:

Output
Installer verified

Nota: Si el resultado dice Installer corrupt (Instalador dañado), deberá repetir el proceso de descarga y verificación hasta que tenga un instalador verificado.

El siguiente comando descargará e instalará Composer como comando para todo el sistema llamado composer, bajo /usr/local/bin:

  1. sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Verá un resultado similar a este:

Output
All settings correct for using Composer Downloading... Composer (version 1.10.5) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer

Para comprobar su instalación, ejecute lo siguiente:

  1. composer
Output
______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.10.5 2020-04-10 11:44:22 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. --no-cache Prevent use of the cache -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug ...

Esto comprueba que Composer se instaló con éxito y está disponible en todo el sistema.

Tutoriales relacionados

A continuación, se ofrecen los enlaces a más guías detalladas relacionadas con este tutorial:

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author

Erika Heidi
Erika Heidi
Author
Developer Advocate
See author profile

Dev/Ops passionate about open source, PHP, and Linux. Former Senior Technical Writer at DigitalOcean. Areas of expertise include LAMP Stack, Ubuntu, Debian 11, Linux, Ansible, and more.

Still looking for an answer?

Was this helpful?


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Creative CommonsThis work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.