Installing Composer on Ubuntu 15.04


In this post you’ll learn how to install on Ubuntu 15.04 globally as well as locally. There are two way to install as given below:

  1. Installing composer globally
  2. Installing composer locally

Installing Composer Globally

In this section you’ll learn how to install composer globally on your Ubuntu 15.04 machine. let’s start!

Installing ‘curl’ Library

Before installing composer you need to install a PHP library named curl, Curl is used to get files form FTP, GOPHER and  HTTP Server. Prompt to your home directory and install curl by running the following commands:

cd ~/
sudo apt-get install php5-curl

 Installing Composer

Now we are ready to install composer. Run the following command to install composer

curl -sS https://getcomposer.org/installer | sudo php

This will install composer in our home directory. Consequently you can see a file named as composer.phar (phar: PHP Archive) in your home directory.

If, for some reason, the above command doesn’t work for you then try this one:

php -r "readfile('http://getcomposer.org/installer');" | php

Making This Global

now we need to move composer.phar file in the your bin directory’s subdirectory composers. Run the following command to do so:

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

You’ve installed composerv globally. But if you need to install composer locally keep reading otherwise you don’t need to read further, you’ve done. You can, now, use composer to install any of your desired PHP Framework such as Laravel 5, Zend FrameWork 2, Yii2 and etc.

Installing Composer Locally

In this section you’ll learn how to install composer locally on your Ubuntu machine. let’s start!

Step -1 Installing ‘curl’ Library

Before installing composer you need to install a PHP library named curl, Curl is used to get files form FTP, GOPHER HTTP Server. Prompt to home directory and install curl by running the following commands:

cd ~/
sudo apt-get install php5-curl

Step – 2: Prompt to Your Desired Directory

Prompt to the directory where you want to install the composer. For example we want to install composer in /var/www/html/ which is root directory in Ubuntu. Run the following command to prompt to the root directory:

sudo /var/www/html/

Step – 3 : Installing Composer

Now, as we have decided the directory where to install the composer, let’s install the composer by running one of the following commands in our Ubuntu 15.04 terminal:
curl -sS https://getcomposer.org/installer | php

If for some reason the above command doesn’t work for you then try this one:

php -r "readfile('https://getcomposer.org/installer');" | php

Hopefully one of these would install composer in your root directory. If you have any problem feel free to ask about it using comments. 

Leave a Reply

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