8

I'm new on Unix-like systems, and using Ubuntu now. Experiencing trouble trying to install Composer with command:

(sudo) curl -sS https://getcomposer.org/installer | (sudo) php mv composer.phar /usr/local/bin/composer 

*tried with and without sudo

After this, I'm getting kinda information about certificates and nothing else:

Certinomis - Root CA
====================
-----BEGIN CERTIFICATE-----
MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjETMBEGA1UEChMK
Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAbBgNVBAMTFENlcnRpbm9taXMg
LSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMzMTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIx
EzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRD
ZXJ0aW5vbWlzIC0gUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQos
P5L2fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4kkjW4znuzuRZWJflLieY6pOo
d5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9n+ws+hQVWZUKxkd8aRi5pwP5ynap
z8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDFTKWrteoB4owuZH9kb/2jJZOLyKIOSY00
8B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb5nPJWqHZZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09x
RLWtwHkziOC/7aOgFLScCbAK42C++PhmiM1b8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE
6OXWk6RiwsXm9E/G+Z8ajYJJGYrKWUM66A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJwx3t
FvYk9CcbXFcx3FXuqB5vbKziRcxXV4p1VxngtViZSTYxPDMBbRZKzbgqg4SGm/lg0h9tkQPTYKbV
PZrdd5A9NaSfD171UkRpucC63M9933zZxKyGIjK8e2uR73r4F2iw4lNVYC2vPsKD2NkJK/DAZNuH
i5HMkesE/Xa0lZrmFAYb1TQdvtj/dBxThZngWVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGj
YzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I
6tNxIqSSaHh02TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsF
AAOCAgEAfj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/0KGRHCwPT5iV
WVO90CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWwF6YSjNRieOpWauwK0kDDPAUw
Pk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZSg081lLMSVX3l4kLr5JyTCcBMWwerx20RoFAX
lCOotQqSD7J6wWAsOMwaplv/8gzjqh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJ
y29SWwNyhlCVCNSNh4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9
Iff/ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8Vbtaw5Bng
DwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwjY/M50n92Uaf0yKHxDHYi
I0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nM
cyrDflOR1m749fPH0FFNjkulW+YZFzvWgQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVr
hkIGuUE=
-----END CERTIFICATE-----
CACERT;
    }
}

(it's just a part of the a big message)

Any advices? Thanks in advance

4 Answers 4

14
sudo apt-get update
sudo apt-get install curl php5-cli git

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

This will download and install Composer as a system-wide command named composer, under /usr/local/bin. The output should look like this:

#!/usr/bin/env php
All settings correct for using Composer
Downloading...

Composer successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

To test your installation, run:

composer

Or in some cases

php composer
1
  • 2
    Seems to be a spurious space in --install-dir in the curl command chain: sudo php -- --install-dir=/usr/local/bin --filename=composer fixes it.
    – John Reid
    Dec 13, 2016 at 13:21
4

As of Ubuntu 15.10 (wily) you can install Composer from the Ubuntu Apt package repository:

apt-get install composer

In Ubuntu 15.10 and 16.04 this package contains a pre-1.0 beta version of Composer, but don’t worry — it is very stable (Composer 1.0 was released in April 2016, but it was widely used way before then).

2
  • 1
    it doesn't have composer self-update command though. Any idea why? Sep 25, 2016 at 9:52
  • @MubasharAbbas it is meant to be upgraded by apt. If self-update were available this would override files downloaded by apt, thus making possible conflicts on next apt upgrade.
    – PeterM
    Aug 16, 2017 at 16:50
0

Steps to install Composer in ubuntu

Step - 1: Check is curl installed or not.

If yes please ignore this step, else first install curl.

As per your PHP version install curl

PHP 5

sudo apt-get install php5-curl
sudo service apache2 restart

PHP 5.6

sudo apt-get install php5.6-curl
sudo service apache2 restart

PHP 7.0

sudo apt-get install php7.0-curl
sudo service apache2 restart

Step - 2: Install Composer with the following command

sudo apt-get update
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

After successful install run following command in terminal to verify is composer successfully installed.

 composer

It will give result in a terminal something like below. enter image description here

0

For the latest Ubuntu versions:

Download the Composer installation file:

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

Create a shell variable and store the latest hash from the Composer page:

HASH="$(wget -q -O - https://composer.github.io/installer.sig)"

Verify the installation script is safe to run:

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

If the output is Installer verified then proceed to next step or if it is Installer corrupt then again start from first step.

To install the latest version:

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

To install a specific version of 1.x, lets say 1.10.26:

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

To install a specific version of 2.x, lets say 2.2.21:

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

Check the composer installation:

composer

Update to any specific version, lets say 2.2.21:

sudo composer self-update 2.2.21

To downgrade version from 2.x to 1.x:

sudo composer self-update --1

To rollback to original installed version:

composer self-update --rollback

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .