Magento 2 Tutorials

Installing Magento 2 With Composer

install magento 2 using composer

Thinking of installing Magento 2 with Composer, but not sure how to do it? Don’t worry, you’re at the right place!

There is official documentation on how to do it, so this is merely an alternate step-to-step guide if you want to skim and not read the entire documentation. So, today we are going to learn how to install Magento 2 using composer. We plan to keep this guide updated with newer Magento 2 code drops, so bookmark this page check back from time to time!

Before performing Magento 2 composer installation, do check these Magento 2 installation requirements.

Steps on How to Install Magento 2 with Composer

1. Install Composer

You can skip this step if you’ve already installed the Composer. (Windows users have an installer available.)

curl -sS | php

1.1 Make Composer Globally Available

If you wish, you can additionally install Composer globally so you don’t have to type php/path/to/composer.phar every time. The Windows installer will automatically set up the PATH system variable.

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

2. Download Magento 2

Run the following command in the root directory.

composer create-project --repository-url= magento/project-community-edition .

3. Set Up Permissions

After all the dependencies are retrieved, you should set the correct permissions on the entire Magento 2 installation directory. The official documentation recommends chmod’ing all directories to 700 and all files to a level of 600:

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

In case you are still facing problems, you are probably logged in under a different user and have to give ownership of the installation directory to the web server user.

4. Create The Database

Given that you already have a MySQL user with the correct permissions, then create an empty database to work with. If you want to, you can also use an existing database and pick a table prefix during the installation process, but that’s not something a lot of people do.

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

5. Install Magento 2

That’s about it! You can now follow the installation wizard or use the command line.

5.1 Installation Wizard

Just fire up the browser, navigate to the host where you installed Magento 2 and if everything went correctly, you should be redirected to the setup tool.

5.2 Command Line Installer

Magento 2 ships with a command line installer and can be invoked as followed:

php bin/magento setup:install 
--admin-email="[email protected]" 

The above command should be edited to your needs and executed from the Magento 2 root directory. What follows, is a bit of scrolling text and if everything went correct, you are informed that the installation has been completed.

6. Useful Tip

This tutorial covered the manual installation of Magento using composer. There are many hosting providers that provide Magento installation on a single click. Shared hosting providers use cPanel that have Softaculous which has many Magento versions available as one click.

If you are looking for an optimized, secure hosting provider then Managed hosting providers like Cloudways, Nexcess, MGT-Commerce is better suited.

Currently, Cloudways is offering $25 FREE hosting credit on Magento hosting. You can avail this offer by using the Promo Code: MGT25.

 Final words

Hopefully, this is a clear guide on how to install Magento 2 using Composer. Most of this information is simplified and readily available with more depth in the official documentation. In case we missed anything or you’d like to know more about, you can always leave a comment below, and we’ll get back with a solution!

Follow us on Twitter →

Subscribe Newsletter

Subscribe to get latest Magento news

40% Off for 4 Months on Magento Hosting + 30 Free Migration