Magento Tutorials

How to Install Magento 2 Using Composer

magento-2-composer

Welcome back to another SimiCart’s technical tutorial. Today, we will guide you how to install composer and how to install Magento 2 with composer.

Step 1: Install Composer

  1. Run the following command to check if the composer has already been installed:
composer --help
composer list --help
  1. If nothing displays or you face any errors, please install Composer:

Create an empty directory on your Magento server and run the following commands:

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
  1. Run the following command to make your composer globally available
mv composer.phar /usr/local/bin/composer

Step 2: Download Magento 2

Run the following command in the root directory.

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition .

Step 3: Set Up Permissions

You should set right permissions for the whole Magento 2 installation directory by running the below command:

find . -type d -exec chmod 700 {} \; && find . -type f -exec chmod 600 {} \;

Step 4: Create The Database

Create an empty database to work with MySQL in case you have already have correct permissions:

echo "CREATE DATABASE magento2" | mysql -u[mysqluser] -p

Step 5: Install Magento 2

Run the following lines in Command Line to install your Magento 2:

php bin/magento setup:install 
--base-url="http://yoururl.com/" 
--db-host="localhost" 
--db-name="dbname" 
--db-user="dbuser" 
--db-password="dbpass" 
--admin-firstname="admin" 
--admin-lastname="admin" 
--admin-email="user@example.com" 
--admin-user="admin" 
--admin-password="admin123" 
--language="en_US" 
--currency="USD"
--timezone="America/Chicago" 
--use-rewrites="1" 
--backend-frontname="admin"

The above values are just examples, you definitely should change them according to your own info.

 

Related posts:
How to Install Magento 2 on Ubuntu 16 Using Nginx
How to Install Magento 2 on Localhost
How to Install Magento 2 on WAMP Server Localhost

How to Install Magento 2 Using Composer
5 (100%) 5 vote[s]
6 Comments

Dom

A knowledge craver who always strive to be wiser everyday.

    avatar
    5 Comment threads
    1 Thread replies
    0 Followers
     
    Most reacted comment
    Hottest comment thread
    6 Comment authors
    imgindiaMasukDomParminder singhSyed Muneeb Ul Hasan Recent comment authors
      Subscribe  
    newest oldest most voted
    Notify of
    vrms
    Guest
    vrms

    >> Run the following command in the root directory

    that is not the root directory ‘/’ of your linux server, right? If that assupmtion is correct wouldn’t …

    “Run the following command in the directorz of your linux server that you want to install Magento in. A common method would be to create a system user for a Magento store and use the /home directory of that user to install Magento”

    … be a little bit more precise instrucion?

    Syed Muneeb Ul Hasan
    Guest

    Hello,

    Thanks for sharing this easy to follow guide to install Magento 2 using composer. Well, I want to ask that for installing any specific Magento 2 version rather than the latest, what will be the CLI command?

    Thanks!

    Parminder singh
    Guest
    Parminder singh

    Is this possible to install Magento direct to the hosting via composer? not localhost, I want to install to the dreamhost vps

    Masuk
    Guest

    Excellent, I learned a quick command and it is faster to install magento.

    imgindia
    Guest

    Thanks for sharing such useful information in the blog. This is a quick guide to learn installing magneto.