This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

How to Install Magento 2 via Composer (A Step-by-Step Guide)

Updated on September 29, 2022

8 Min Read
install Magento 2 via Composer

The development team of Magento 2 makes it a great platform for an ecommerce store, but sometimes it’s not easy to get started with even if you’re a developer.

Composer, a tool for dependency management within Magento 2, allows you to download the libraries of Magento 2. Developers usually follow the long manual process to download Magento 2 and then face difficulty in managing it. This is where Composer comes in for a hassle-free experience.

From this point, simply understand that from Magento 2.4 onwards, the Command-Line Interface (CLI) plays an important role, so you can consider installing Magento 2 via Composer. Yet, store owners are worried about how to install Magento using composer, its packages, and hosting requirements.

In this tutorial, I’ll tell you the advantages of installing Magento 2 via Composer and how you can do it with easy steps.

Advantages of Installing Magento 2 via Composer

Installing Magento 2 using Composer helps manage its components and their dependencies. Using Magento 2 Composer to get its software metapackage has the following advantages:

  • Reuse third-party libraries without bundling them with Magento 2 source code.
  • Reduce Magento extension complexity and compatibility issues by using a component-based architecture with robust dependency management.
  • Adhere to PHP-FIG (Framework Interoperability Group) standards.
  • Repackage Magento 2 code with other components.
  • Use Magento 2 in a production environment.

If you are wondering how to easily install Magento 2 using Composer, follow this simple step-by-step guide on installing Magento 2 using Composer.

Requirements for Running Magento 2 Store

Before we can move into the section for Magento 2 installation using composer, please check the following:

Launching Magento 2 on Cloudways Is as Easy as 1-2-3

Cloudways Platform is built for ecommerce store owners who want to focus on business growth without wasting their time on technicalities.

How to Install Magento 2 via Composer

This method to install Magento is a bit complicated and time-consuming. We will try to cover every possible detail to install Magento using composer successfully.

Step 1: Install Magento Composer

1. Open the terminal or command prompt and run the following command to check if Magento composer has already been installed:

composer –help
composer list –help

composer command

2. If nothing displays or any error, please install the Magento composer:

Create an empty directory on your server or system directory to install Magento 2 with composer and run the following commands:

curl -sS | php
mv composer.phar /usr/localhost/bin/composer

You have successfully installed Magento composer in the directory /usr/localhost/bin/composer.

For Windows:
You can also manually download the composer from Getcomposer site.

3. After this, check the Composer version with the following command:

composer -v

Please Note: If you face any technical issues, please free to ask and for more information, please refer Magento official documentation.

Step 2: Login As a File System Owner

1. Access the directory and folder in which you want to install Magento 2 i.e., public_html or var/www/html/magento2. Note if you are login into the Magento server, change the server directory file system owner to a user with permissions to write the Magento file system.

Install Magento 1

2. Add <magento_root>/bin to your system PATH to run Magento commands from any directory.

export PATH=$PATH:/var/www/html/magento2/bin

Optionally, you can run the commands in the following ways:

cd <magento_root>/bin and run them as ./magento <command name>
<magento_root>/bin/magento <command name>
<magento_root> is a subdirectory of your web server docroot.

Please follow the instructions further to download the Magento Meta package

Step 3: Download Magento

You can download Magento 2 version directly from its official website


Run a command using composer to download specific Magento 2 version


composer create-project --repository-url= 
magento/project-community-edition <install-directory-name>

Magento Open Source

composer create-project --repository-url= 

Adobe Commerce (Enterprise)

composer create-project --repository-url= 

In magento installation by the above command you can specify the specific version of Magento (2.0, 2.1, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.2.6, 2.3, 2.4).

Note: To install Magento 2 using composer in the current directory (e.g., public_html), do not forget to add the (.) dot at the end.

During this process, before downloading Magento, you would be asked to Insert your username and password. For username and password, log in to Magento Marketplace and select My Account from the top-right corner. Now click Access Keys and Generate your new SECURE KEYS.

  • Public Key: Is your username
  • Private Key: Is your password

After inserting your username and password, it will ask for store credentials. Type “Yes.”

Then Magento 2 will now start downloading on your server.

Install Magento 4 Download Magento

Step 4: Set Permission to Install Magento 2.4

To install Magento 2, you now need to set proper permissions for your Magento 2 Store. Magento has a set of recommended permissions which we have to apply.

a ) The owner must have full access to files.

b ) Web Server must have write permission on var, app/etc and pub directory.

c ) Execute permission of bin/magento.

Some permissions command need to be run for it


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 5: Create Database for Magento installation

Create and empty database with MySQL/MariaDB


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

Step 6: Install Magento 2.4

Now, the install Magento command needs to be executed


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

The above command ensures that base-url is “http://yoururl/” your application url, db-host is the hostname or IP address of the server, db-name is the name of database, db-user is the username of the database and db-password is the password of your database. You can customize the admin’s first name, last name, and other parameters.

Note: This command is executed with dummy data. You need to fill in this information based on your application information.

This command is executed with dummy data. You need to fill this information based on your application information.

You have successfully installed Magento 2 using Composer. Let’s get started with configurations.

Now run the readiness check and start your Magento store

Magento Installation Steps

Let’s Check Out the New Magento 2 Application.

After a successful Magento 2 installation on your Cloudways server using composer, this is how your Magento 2 Frontend and Backend should look like.


Magento Frontend


Magento Application Login Credentials

Note: If you are installing Magento 2 using composer and want to configure Varnish on it, then follow this tutorial How To Setup Magento 2 With Varnish.

How to Install Magento 2 on Cloudways

Since installing Magento 2 requires a lot of effort, store owners do not want to waste their time on technical stuff; instead, want to be more focused on their business growth. They prefer a solution that caters to their needs. This is where Cloudways Platform comes in handy!

Cloudways Platform is based on UI; even a non-technical person can manage his server and Magento application in a few clicks. Also, Cloudways fulfills all the server requirements for running a Magento 2 smoothly.

Now let’s see how you can install Magento 2 in simple steps.

Step 1: Signup/Login Your Account

Sign up for Cloudways if you don’t have an account yet or log in if you’re already a Cloudways user.

Install Magento 7 Cloudways Signup

Step 2: Select Magento Application

After login, create a server and select the version to install Magento from your Application dropdown. Also, provide details for your server and application name.

Select Application:

Select apps - Cloudways platform

Fill in the remaining fields to install Magento.

application & server details - cloudways platform

Step 3: Choose Cloud Providers

Select the Cloud Provider of your choice.

Install Magento 10 Providers

Step 4: Select Server Size & Bandwidth

Select Server Size & Bandwidth according to your requirements.

Install Magento 11 Server Size

Step 5: Define Server Storage

Now, select your Server Storage. You can always scale up whenever required.

Install Magento 11 Server Storage

Step 6: Select Server Location

Select your server Location by keeping the latency factor in mind.

Install Magento 13 Server Location

Now click on the Launch Server button from the bottom of the page and wait for your server preparation.

Launch now cloudways

Go to your Server and check server and application details

Once the server is ready, go to Application Management from the top menu bar and log in to your Magento 2 store using the Access Details.

Server Details:

Install Magento 14 Server Details

Application Details:

Install Magento 15 Application Details

Check your Application

Install Magento 16 Application

Final Words

This is everything on how to install Magento 2 using Composer. Your very own Magento 2 store is now ready for customization! Add products and start expanding your business online. Don’t forget to reap the benefits that Magento managed hosting that Cloudways offers!

Install Magento 2 FAQs

Q: How do I install Magento 2?

To install Magento 2 follow these 5 steps

  • Step 1: Setup the server and fulfill the Magento requirements
  • Step 2: Install Composer
  • Step 3: Download Magento 2
  • Step 4: Set Permission to Install Magento 2
  • Step 5: Create Database for Magento installation
  • Step 6: Install Magento 2

Q: What is the command to install Magento 2?

Once Magento 2 to is downloaded run this command to install Magento

  • Command: php bin/magento setup:install

Q: What is the role of Composer in Magento 2?

Magento 2 uses a composer, as a dependency manager, to maintain and upgrade the Magento components. Composer is linked to Magento code for developing any Magento component the key part is it reads the composer.json file in Magento’s root directory to download the dependencies listed in the file. We recommend installing composer first.

People also searched for:

  • Magento 2 install
  • Magento 2 install Composer
  • Install Magento 2 using Composer
  • Magento 2 install command line
  • Magento 2 composer
Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”

Stefan [Management Consultant]

Abdur Rahman

Abdur Rahman is the Magento whizz at Cloudways. He is growth ambitious, and aims to learn & share information about Ecommerce & Magento Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Unleash The Cloud.
Not Budgets.

For 4 Months +
Up To 30 Free Migrations

Cyber Week

Time Left In Offer
  • 0


  • 0


  • 0


  • 0


40% OFF

On All Plans