🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Install Magento 2

By Sanjay JethvaUpdated on Jul 15, 2025 3 min read

If you are visiting this post that means you are on the stepping stone in E-commerce world! And, you have made the right choice to select Magento 2 as the platform. I’ll guide you through the installation process of Magento 2.

Make sure you fulfill some basic Magento 2.x system requirements prior to installing Magento 2. You can also install Magento 2 via command line.

There are three ways to install Magento 2:

1. Install Magento 2 from the Archive File

  • Visit the Magento Download Page. Download the latest Magento 2 package from any of the archive types (zip, tar.gz, tar.bz2), with or without sample data.
  • Now upload the zip file to the server and extract it to Magento root directory.
  • For shared hosting users, you can unzip or extract the package.
  • For the local server, follow the commands below:
# File .tar.gz	
tar zxf 

# File .zip
unzip 
  •  Run below command to add write permission for var, app/etc, pub folders.
chmod 777 -R var
chmod 777 -R app/etc
chmod 777 -R pub
  • Now run Magento setup wizard and finish installation process.

2. Install Magento 2 via composer

A composer is a tool for dependency management in PHP. To learn more about the composer, visit https://getcomposer.org/doc/00-intro.md

Similar to above method, Magento core code is stored under /vendor directory and updating is possible through Magento admin.

Collect your authentication keys from here. Navigate to “My Access Keys”, enter a descriptive “Name” and generate a new set of keys.

Enter the following command in the terminal:

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

Your public key is the username, and the private key is the password which is needed to be entered after which the Magento 2 is ready to install. Just go through the Setup Wizard and install it now.

That’s it for the installation of Magento 2 via composer without sample data.

Now I’ll show you how to install sample data. Navigate to Magento 2 root directory through the terminal, and run the following command:

php bin/magento sampledata:deploy
php bin/magento setup:upgrade

When you run the above two commands, composer.json file will be updated and the sample data will be installed. If you are asked to re-run the Magento compile command, enter the following:

php bin/magento setup:di:compile

Sit back and wait for some time while the command is being executed.

3. Install Magento 2 via Github

Follow the below steps:

git clone [email protected]:magento/magento2.git
  • Wait for the deployment to be finished.
  • Enter the following command:
composer install

Install Magento 2Example of the command that installs Magento 2. Check the base-url, db-name, db-password, admin-email, and admin-password to match your local setup.

php -f bin/magento setup:install –base-url=<server-url> --backend-frontname=<admin-url-key> --db-host=<db-host-name> --db-name=<db- name> --db-user=<db-user-name> --db-password=<db-password> --admin-firstname=<admin-firstname> --admin-lastname=<admin-lastname> --admin-email=<admin-mail-id> --admin-user=<admin-user> --admin-password=<admin-password> --language=<your-locale-language> --currency=<default-currency> --timezone=<timezone> –use-rewrites=1
  • Open your browser and visit your local link
  • Magento 2 is now installed!

To install Magento 2 via Github with sample data, follow the below steps:

  • Go to the web root which is not Magento 2.
  • Run the below command:
git clone [email protected]:magento/magento2-sample-data.git
  • Navigate to cloned Magento 2 directory.
  • Run the below command:
php -f dev/tools/build-sample-data.php -- --ce-source="your Magento CE install dir"

Symlinks to your Magento 2 installation are created.

  • For Linux machine, you need to set ownership and permissions:
chown -R :your web server group name
find . -type d -exec chmod g+ws {} ;
  • Clear cache. Navigate to the Magento 2 var/ folder and run the below command:
rm -rf cache/* page_cache/* generation/*
  • To install the sample data, run the below commands:
php bin/magento setup:upgrade
php bin/magento setup:di:compile

So that was all about Magento 2 installation

You can always refer the https://experienceleague.adobe.com/docs/commerce-operations/installation-guide/overview.html

Best wishes for your online store success with the help of latest Magento 2.4.6 features and security!

Feel free to share the tutorial with Magento Community via social media

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.