Installing Composer on Ubuntu 15.04

In this post you’ll learn how to install composer on Ubuntu 15.04 globally as well as locally. There are two way to install composer 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 Installation 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s