I cannot install php composer in Ubuntu 16.04
Solution 1
sudo apt-get install composer
... worked for me, and will additionally install all of the dependencies. Or, as @Jonathon mentions above, use the synaptic package manager to install composer. Note that this will get you the latest stable composer, not the devel version that you get from doing it on the command line from getcomposer.org
Solution 2
Install PHP Composer on Linux machine.
To run below command to Update your packages:
sudo apt-get update
To run below command to Install the curl utility:
sudo apt-get install curl
To run below command to Download the installer:
sudo curl -s https://getcomposer.org/installer | php
To run below command to Move the composer.phar file:
sudo mv composer.phar /usr/local/bin/composer
Test composer installed
composer
Solution 3
I have installed composer by running few commands for my Ubuntu 16.04 - laravel PHP application server.
Setup in home directory :
cd ~
Install Curl to get the composer library:
sudo apt-get install curl
Installing composer:
sudo curl -s https://getcomposer.org/installer | php
Move the composer file to bin path :
sudo mv composer.phar /usr/local/bin/composer
Verify composer installation :
composer
Solution 4
Try this
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer
Related to this issue https://github.com/composer/composer/issues/5510. Hope it also fixes yours
Admin
Updated on July 21, 2022Comments
-
Admin almost 2 years
I have this error when I try to install composer:
Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible. If possible you should enable it or recompile php with --with-openssl
I followed this steps from my terminal in the Downloads directory:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"
Just like the website says. What can I do now? I'm using Laravel but I need composer first. I have seen on internet that it's something to do with extensions but I don't know how to it.
Hope someone cal help me with this!
Thanks in advance.