How to Install Magento 2 using Composer?

Install Magento 2 Using Composer

From Magento version 2.4.2 onwards, you can only install Magento with the command-line method.

But Composer comes with several advantages that make it worth installing Magento using Composer.

Let’s see the advantages of using Composer, and how to use Composer to install Magento 2.

What is Composer?

Composer is a dependency manager that doesn’t just fetch libraries and their dependencies but also manages versions of those libraries. It installs them in a directory, known as a “vendor” directory in the root of your project, and symlink those libraries to your code so that you can use them.

Advantages of using Composer:

  • No need to bundle third-party libraries with Magento 2 source code
  • Adhere to PHP-FIG (Framework Interoperability Group) standards
  • Use Magento 2 in Production Environment
  • Reduce Magento extension complexity and compatibility issues by using a component-based architecture with robust dependency management
  • Repackage Magento 2 code with other components.

Installing Magento 2 Using Composer

The five steps process to install Magento 2 with Composer is:

  1. Install Composer
  2. Download Magento 2
  3. Permissions
  4. Create Database
  5. Install Magento 2

Step 1: Download & Install Composer

First, check whether the Composer is already installed or not. Run the following command to check:

composer --help
composer list --help

Nothing comes up? It means the Composer is not installed yet. It means you have to download and install the Composer.

Create an empty directory on the Magento server, and run this command:

curl -sS | php

The Composer is installed. Run the following command to make the Composer globally available:

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

Step 2: Download Magento 2

To download Magento, you have to execute the following command in the root directory:

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

Add the edition you wish to download, for example. For Magento 2.4.2, add the 2.4.2.

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

Step 3: Permissions

Magento 2 is downloaded on the system. Now, you need to set up the correct file permissions to install it.

Run the command to set up correct permissions:

find . -type f -exec chmod 644 {} \;            
find . -type d -exec chmod 755 {} \;        
chmod -Rf 777 var
chmod -Rf 777 pub/static
chmod -Rf 777 pub/media
chmod 777 ./app/etc
chmod 644 ./app/etc/*.xml
chmod -Rf 775 bin

Step 4: Create Database

Run the commands to create an empty database that works with MySQL.

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

Step 5: Install Magento 2

Finally, run the below command to install the Magento 2 application.

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

The placeholder has been used for the values in the code. Please change them accordingly.

Let’s see what these values are.

Base URL: Path where the Magento directory is. Format is: HTTP(s)://<host or IP>/<Magento install dir>/

DB Host: Hostname or IP Address of the host

DB Name: Name of the database. Please change it to the DB name you created in Step 4.

DB User: User with all the permissions to manage the DB.

Admin First Name: First Name of the Administrator

Admin Last Name: Last Name of the Administrator

Admin Email: Email Address of the Administrator

Admin Username: Username that will be used to log into Admin panel by Administrator

Admin Password: Administrator Password

Language: Language of Admin panel and storefront. Language codes like en_US have to be used.

Currency: Default currency to be used in the storefront. For the supported currencies and their code, enter php bin/Magento info:currency:list

Timezone: Add the timezone or time zone you want your store to run on.

Use Rewrites: Add 1 to enable web server rewrites. 

Backend Frontname: This is your admin URL. You should add an easy-to-type URL here. Omitting it will create the randomly generated URL for the admin path.

Search Engine: The default elastic search engine is Elasticsearch 7. Add the Elasticsearch version that you want to use for the Magento installation.

Elasticsearch Host: The hostname or IP Address to run the Elasticsearch. The default is localhost.

Elasticsearch Port: Port number for Elasticsearch. Default is 9200.

For more configuration, check the official Magento guide.


Wait for some time as the Magento is installed. If everything went write, you would see this message:

Post-installation file permissions check…
  For security, remove write permissions from these directories: 'C:/xampp/htdocs/magento24/app/etc'
  [Progress: 1270 / 1270]
  [SUCCESS]: Magento installation complete.
  [SUCCESS]: Admin Panel URI: /admin
 Nothing to import.

And it is done. You have successfully installed the Magento 2 using Composer.

Installing Magento 2 Using Breeze

You do not have to execute code and run commands to install Magento.

Breeze comes with an intuitive interface that you can pick up from the first minute to set up your Magento store.

  1. Sign up on Breeze
  2. Create your first server
  3. Enter Project name, select Cloud, and server location
Install Magento with Breeze Select Cloud
  1. Select your Plan. Check all pricing options.
Install Magento with Breeze Select Plan
  1. Add your Card.
Install Magento with Breeze Add Card

If you want to try the platform first, please use live chat to book a demo.

  1. Select Magento version, add basic information to set up Magento store. Click Deploy.
Install Magento with Breeze Essential Information

That’s it. Your store is ready.

Without running a single script, checking requirements, or creating databases.

Breeze will do everything – start selling and scale as your business grows. Use the Breeze dashboard to manage your Magento store.

Breeze Dashboard

Final Words

This quick tutorial showed you how to install Magento 2 using Composer in 5 steps.

If you do not want to go through 5 steps and run commands, Breeze would be a better option for you. You can set up a Magento store that loads in seconds, with regular backups and secure infrastructure from the visual platform.

All at the cost of Magento hosting.

I hope this article helps you to build a Magento store. Add your products, and start your eCommerce journey on the right foot.

If there is any question or issue, please leave it in the comment box.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new plugins, and more. 100% Magento Goodness, a promise!

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

Talk to a sales representative

USA / Worldwide




We can help you. Right now.

Fast growing merchants choose Breeze for high-performance hosting. Experience counts. Let's get started.

Request demo

Please fill in the details below and we’ll reach out to you with a customized demo of our product!


75% OFF on

Receive the coupon as soon as you
submit the email address. πŸš€