Magento 2 Installation Guide: Composer, GitHub, and ZIP Methods

Table of Content

Magento 2 installation guide
Last Updated: June 26, 2025

Amasty's team first decided to install Magento 2 as soon as its 0.42.0-beta1 version emerged in 2014. Since then, we’ve performed hundreds of thousands of Magento 2 installations for our clients. 

That’s why, to make starting Magento for beginners easy, we decided to provide an in-depth Magento 2 installation guide. We address common methods, best practices, and possible errors.  

Magento Installation Methods: An Overview

There are three primary methods to install Magento 2, each offering a distinct approach depending on your technical preference and environment:

  1. Using Composer

  2. Via GitHub

  3. From an Archive (ZIP)

The Composer method is the most recommended and beginner-friendly. It allows you to install Magento with a single command, leveraging Composer’s powerful dependency management system. Magento Composer installation ensures a clean, modular, and easily maintainable store.

The GitHub method involves cloning the Magento 2 codebase directly from the official repository. This approach is best suited for developers who want direct access to the latest source code and are comfortable working with Git and managing updates manually.

The Archive (ZIP) method involves downloading Magento as a compressed archive and extracting it into your web server’s root directory. Although it may appear simpler, it still requires command-line interaction for dependency installation and permissions setup.

Need Help with Installing Magento?

Reach out to Amasty's Magento team for a consultation or hands-on assistance.

Localhost vs. General Magento Installation

It’s important to distinguish between localhost installations and general (production or staging) installations:

  • A localhost installation refers to setting up Magento on your personal computer or local server, ideal for development, testing, or learning. Common tools for this include Ubuntu (native or VM) or XAMPP for Windows/macOS.

  • A general installation is done on a remote or cloud server, typically intended for production or public-facing stores. It requires additional considerations such as SSL, domain configuration, and hosting scalability.

In this Magento 2 installation guide, we’ll cover all three methods and explain the specific requirements and steps for both local and remote setups. 

Method 1: How to Install Magento 2 with Composer

Installing Magento via Composer offers several advantages:

  • Enables the use of third-party libraries without modifying the core source code

  • Minimizes the risk of code conflicts during development and upgrades

  • Allows for precise control over dependency versions

  • Supports semantic versioning for better version management

  • Adheres to the PHP Framework Interoperability Standard (PSR)

So, what are the steps to install Magento 2 using Composer? Let’s walk through them.

1. Install Composer 

Before installing Magento, make sure that Composer is set up on your server. Use it to download the Magento 2 codebase. 

2. Log in as File System Owner

Log in to the Magento server as the file system owner, or switch to a user with permissions to write to the Magento file system. If you use the bash shell, use the following directive to switch to the Magento file system owner and enter the command at the same time:

su -s /bin/bash -c

If you want to run Magento commands from any directory, add <magento_root>/bin to your system PATH. Here is the CentOS bash shell sample:

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

3. Get the Package

To get the Magento metapackage, do the following:

  • Log in to your Magento server as the Magento file system owner or switch to it.

  • Change to the docroot directory of the web server or to the directory that you configured as the virtual host docroot.

  • Create a new Composer project with the Magento Open Source or Magento Commerce metapackage using the following command:

Magento Open Source:

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

Magento Commerce:

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

During the Magento 2 installation process, you'll be prompted for authentication credentials. You need a set of Magento Marketplace keys for this step. If you don't have these keys, create a Magento Marketplace account, navigate to the "My Profile" section, and generate the keys in the "Access Keys" tab.

Composer allows you to customize your Magento 2 setup. Explore options like choosing sample data inclusion, specifying your desired PHP version, and more. Refer to the Composer documentation for additional customization possibilities.

Finally, pay attention to any errors or warnings that may appear during the installation process. In case you need to re-run the Magento compile command, use the following command:

php bin/magento setup:di:compile

Method 2: Magento Installation via GitHub

This method is best suited for people who contribute to the Magento Open Source codebase. To use this method, you should understand Composer and Git commands and be able to update system software and Magento extensions using them.

Installing Magento 2 via GitHub Without Sample Data

Step 1. Clone the Magento 2 repository from Github reps, or download the required release on the Github releases page.

Step 2. Create a new empty directory using this command:

git clone [email protected]:magento/magento2.git

Step 3. After the deployment is complete, enter the command:

composer install

Step 4. Install Magento 2. Here you can see an example of the Magento 2 installation command.

Example is relevant if Magento install directory is magento2ee, the db-host is on the same machine (localhost), and the db-name, db-user, and db-password are all magento:

bin/magento setup:install \
--base-url=http://localhost/magento2ee \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 

Open the browser and visit your local link. Done!

But what if you want to install M2 with sample data?

Installing Magento 2 via GitHub with Sample Data

Step 1. Go to the webroot (not Magento 2).

Step 2.  Clone the Magento 2 directory using  the command:

git clone [email protected]:magento/magento2-sample-data.git

Step 3. Then, navigate to the cloned Magento 2 directory and run the command:

php -f dev/tools/build-sample-data.php -- 
--ce-source="your Magento CE install dir"

Now, symlinks to your Magento 2 installation are created.

Step 4. Next, you need to set ownership and permissions for Linux machine:

chown -R :your web server group name
find . -type d -exec chmod g+ws {} \;

Step 5. Clear cache by going to the Magento 2 var/ folder and running the following command:

rm -rf cache/* page_cache/* generation/*

Step 6. Use the following commands to install sample data:

php bin/magento setup:upgrade
php bin/magento setup:di:compile

Done!

Method 3. How to Install Magento 2 via a ZIP Archive

This is a relatively easy installation method, but it lacks many of the benefits of using Composer. 

Step 1. Navigate to the Magento download page and download the latest Magento 2 version package in the needed archive type (choose whether sample data is needed).

Step 2. Upload the archive to your server, then extract it to the Magento root directory.

You can use the unzip/extract function to extract the Magento package for shared hosting. Or use the following commands if you are running on your server:

# File .tar.gz
tar zxf 
# File .zip
unzip 

Then, add write permission for var, app/etc, pub folders:

chmod 777 -R var
chmod 777 -R app/etc
chmod 777 -R pub

Step 3. Start the Magento installation wizard and walk through the installation process. 

How to Set Up Magento on Localhost

To run Magento on localhost means setting up the platform on your own computer instead of a remote server. 

This installation is especially useful for developers, testers, and learners who want a safe, private environment to experiment with Magento features without risking a live site. It allows for faster development cycles, offline access, and full control over configurations, ideal for building custom themes, testing extensions, or learning Magento 2 from the ground up.

We’ve already mentioned that you can install Magento on localhost via GitHub. Other ways to perform local installations use:

  • Ubuntu (via a native Linux setup, VM, or WSL)

  • XAMPP (an all-in-one package for Windows/macOS)

Each method has its own pros and setup steps, depending on your operating system and development needs.

How to Install Magento on Ubuntu

Ubuntu offers a powerful and flexible environment for Magento development that closely mirrors a real server setup. This section walks you through configuring the LAMP stack, setting up Magento dependencies, and installing Magento 2 using Composer on Ubuntu.

Step 1. Firstly, check the Magento 2 requirements.
Step 2. After that, get the Magento software via Composer or an archive.
Step 3. Now you have to change permissions to read-write to install Magento files with the use of the command line.
Step 4. Next, install M2 on Ubuntu. Enter the following command in the command line:

bin/magento setup:install 
--base-url=http://example.com/ \ --db-host=localhost --db-name=magento --db-user=magento --db-password=magento \ --admin-firstname=Magento --admin-lastname=Admin [email protected] \ --admin-user=admin --admin-password=12345 --language=en_US \ --currency=USD --timezone=America/Chicago --use-rewrites=1 \ --search-engine=elasticsearch7 --elasticsearch-host=es-host.example.com \ --elasticsearch-port=9200

Step 5. Check that everything works. Open your website backend and try to log in to the admin panel with the admin’s username and password.

You can find more information on this Magento 2 setup method with all samples of the code on the How to install Magento 2 on Ubuntu page.

How to Run Magento in XAMPP

XAMPP provides a beginner-friendly way to run Magento locally on Windows or macOS by bundling Apache, MySQL, and PHP into one package. In this section, you'll learn how to configure XAMPP for Magento 2 and complete the installation with minimal system setup.

  1. Download and install XAMPP.

  2. Navigate to the Magento website and get the package.

  3. Go to the xampp/htdocs and make a folder called Magento.

  4. Unzip the downloaded archive in the Magento folder, open the XAMPP Control Panel, and click the Config in the Apache section.

  5. Choose the PHP (php.ini) from the shown menu.

  6. Find these lines: extension=php_intl.dll \ extension=php_xsl.dll. Remove the ; sign at the beginning in an open document.

  7. Return to the XAMPP Control Panel > run Apache and MySQL.

  8. Write localhost/magento2 in the browser and choose the Agree and Setup Magento option.

  9. After that, you have to complete the 6 steps of the Magento 2 installation process. 

  10. Open your browser, write localhost/magento, and localhost/magento/admin. Check if everything works fine.

For more information on this method, go to the How to install Magento 2 on XAMPP page, which describes each step in detail. 

Troubleshooting Magento Installation Challenges  

During the Magento 2 installation process, users may encounter common challenges. This section provides insights and solutions to help you navigate through potential issues:

  • File Permission Errors: In cases where users face file permission issues, review and adjust the ownership and permissions of Magento 2 files and directories. Utilize commands such as chown and chmod to ensure proper access.

  • Database Connection Problems: If the installation fails to connect to the database, verify the correctness of your database credentials, ensuring they match the values specified during the setup.

  • PHP Version Compatibility: Ensure that your PHP version aligns with Magento 2 requirements. Incompatibility issues may arise if the PHP version is too old or too recent.

  • Composer Dependency Resolution: If encountering dependency resolution problems with Composer, run composer install to fetch the required dependencies or update Composer to the latest version. 

Read More: MagentoHow to Start

Get Magento Installed Without the Headaches

Installing Magento 2 can be complex, especially with different methods, system requirements, and potential configuration issues. Whether you're setting up a development environment or launching a live store, even small mistakes can lead to performance or security problems down the road.

To save time and ensure a flawless start, consider using our Magento 2 Installation Service. Our experts will handle the entire setup – from server configuration to database preparation – so you can focus on growing your business, not fixing installation errors.

Let professionals take care of your Magento installation to start smoothly and confidently.

Frequently asked questions

You can download Magento 2 from the official Adobe Commerce website or via Composer using the Magento repository at repo.magento.com.

You need a compatible server (Linux recommended), PHP 8.1/8.2, MySQL 8, Elasticsearch, Composer, and proper file permissions.

Magento Open Source is free; Adobe Commerce (Enterprise) requires a paid license, with costs varying based on business size and features.

Originally published: December 18, 2014
January 12, 2015
December 17, 2014
Comments
Olga
December 18, 2014
You're so fast! It was released just yesterday and you have so great report already. Thanks! It helps to find out what issues other people face with comparing to Magento team, which works with these tools every day. I just have small note. "chown -R admin:www-data /var/www/magento2" It means that you make user "admin" and group "www-data" owners of the files. "www-data" is not a user in this context, so it will work as far as your Apache user is in "www-data" group. It's little bit different than you describe in the explanation. In Magento documentation it's described as "Magento files and directories should be owned by the web server user". Maybe it can be rephrased somehow, the intent was to say that Apache user should have access to the files - "write" for some of them and "read" for all others. In your case Apache user owns the files because he is in "www-data" group, while it's not a real owner. And a question: you say "add write permissions for app/etc/ and vendor/". Could you, please, tell why did you need write permissions to "vendor" directory? Does installation fail, if "vendor" is not writable? Thanks
Reply
Andrey Tataranovich
December 19, 2014
Hi, and thanks for such a great comment! Regarding the user group question – you’re right, and thanks for pointing this out, I’m sure it will be helpful for all those people who’ll come and read the article. As for the second question – I couldn’t find an appropriate description of the directory to give write permissions for and took the information from one of the tickets here https://github.com/magento/magento2/issues/791#issuecomment-66433673 As the release is very fresh the documentation is still far from ideal and many descriptions need details – but the Magento guys pointed out that they will do their best on keeping the documentation up-to-date and precise in the future.
Richard Ireland
December 22, 2014
It's good to know Amasty are on top of Magento 2.0. Any official news on upgrade costs/procedures for existing Amasty customers? I am a big fan of your extensions, and was planning to recommend to a client they purchase some more in the next few weeks. However if they will need to purchase again after a migration to Magento 2.0 I may tell them hold off for a while.
Reply
Ksenia Dobreva
December 22, 2014
Hi, thanks for the question and the kind words! Unfortunately, it is still Developer Beta and we’re in the process of digging in Magento 2. It is still too early to speak about transition to Magento 2 for merchants. According to Elena Leonova from the Magento team (you can see more at https://amasty.com/blog/magento-2-news/) Magento 2 Merchant release is planned in the 4th quarter of 2015, so it’s at least a year before merchants will be able to use the new version to its fullest. Taking these facts into account, I doubt it's worth waiting a year or even more. (If your clients need new features right now or in the nearest future, don’t forget to send them the coupon code – it’s valid till December 28, details here https://amasty.com/blog/merry-christmas-20-off-on-all-extensions/). We updated our terms on Magento 2 support: https://amasty.com/terms-and-conditions.html «Updates for Magento of 2.X.X versions will not be provided for free even if the period of free updates and support will still be running. (…) Magento 2 will be a completely different solution in terms of architecture and will be incompatible with all extensions developed for Magento of 1.X.X versions, including the ones provided by Amasty. Due to this extensions for Magento 2 will need to be developed from scratch and will be treated as completely new extensions, not as new versions of extensions developed for Magento of 1.X.X versions.» Hope that helps. Will be happy to add anything in case you have any other questions.
Vincent ANDRE
January 20, 2016
is that still too early to talk about those upgrade costs and procedures?
yogi
December 25, 2014
have you installed the magento2 successfully? how i can run magento2 under ubuntu with index.php?
Reply
Ksenia Dobreva
December 29, 2014
Hi Yogi! Yes, we have installed Magento 2 successfully. Our instruction is adapted for Debian - so it should work with Ubuntu.
Dennis
April 28, 2015
I've tried it several times but when I want to install the sample-data-patch I always get this error: patch -p1 < magento2-require-sample-data.patch patching file composer.json Hunk #1 succeeded at 7 with fuzz 2. patch unexpectedly ends in middle of line Hunk #2 FAILED at 36. 1 out of 2 hunks FAILED -- saving rejects to file composer.json.rej I've been trying this with Magento 0.74.0-beta6 Any ideas?
Reply
Ksenia Dobreva
April 29, 2015
Hi Dennis, sorry for that, but looks like our instructions became irrelevant with time - things have changes since December. We will consider writing a new post.
Tony
May 13, 2015
Hi, I have installed magento version 2.0 successfully but when go to admin I don't click on any thing Can you help you ? Thank a lots! Regards Tony
Reply
Ksenia Dobreva
May 14, 2015
Hey Tony, thanks for asking. Unfortunately, we couldn't reproduce your bug... Please make sure that your server is equipped according to minimal Magento 2 requirements (pay special attention to the PHP version). If everything is okay with it, and the installation process went without mistakes, but the interface is not working, it can be a good idea to try to install Magento once more, and if the same problem appears, to submit a bug to Magento 2. Hope that helps.
Shawn Adams
August 6, 2015
If we use docker this image clearly help us install magento 2 https://hub.docker.com/r/ilampirai/docker-magento2/ share your thoughts ?
Reply
Ksenia Dobreva
August 12, 2015
Hi Shawn, I've consulted with my colleagues on that question, and they say for now this is more a playground than a way that could be used for staging/production usage. Hope that helps!
sam
August 20, 2015
can you help me how to install magento 2 under ubuntu machine. ? 1. In which directory i need to download composer ? Thanks
Reply
Ksenia Dobreva
August 20, 2015
Hi Sam, thanks for asking. sudo wget -O /usr/local/bin/composer http://getcomposer.org/composer.phar sudo chmod 0755 /usr/local/bin/composer Hope that helps!
Duc
October 29, 2015
Hi, I follow your link to install sample data : but when i finish and reload my page, it don't have anything, just same before i intall sample data. When i am wrong? Can you show me how can install sample data after install magento 2. I installed but nothing.
Reply
Ksenia Dobreva
October 29, 2015
Hey Duc, thanks for asking. Unfortunately, we can't help you right now because things change every time Magento rolls out a small update of version 2, and any instructions can't be stable at all. I think we will be ready to give some steady recommendations when the second version is officially out, but now any instructions usually expire very fast. I think now the best place to ask your question is this topic on Magento forums: https://community.magento.com/t5/Installing-Magento-2/bd-p/installing-magento-2 Hope that helps!
faran
November 25, 2015
Hi, I am facing the problem in ubantu that when I goto directory cd /var/www/magento2 and run composer install, it gives me the following error: [Composer\Downloader\TransportException] Invalid credentials for 'https://repo.magento.com/archives/magento/composer /magento-composer-1.0.2.0.zip', aborting. Kindly let me know which credentials to use and how to resolve this. Will be really helpfull. Thanks
Reply
Ksenia Dobreva
November 25, 2015
Hi Faran, thanks for asking. It's a pretty old instruction, now you can download Magento as an archive from here https://www.magentocommerce.com/download and install it much easier. Our instruction was valid before the official release. Hope that helps!
Jaime
November 30, 2015
I have followed instructions in your page, however, installation always get stuck and different percentages, for example, I have just tried again, it was stuck at 71%. I am using Web Interface. I tried composer and this was shown: Problem 1 - magento/framework 100.0.2 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system. - magento/framework 100.0.2 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system. - Installation request for magento/framework 100.0.2 -> satisfiable by magento/framework[100.0.2]. I tried even this command: php -d xdebug.max_nesting_level=500 -f bin/magento setup:install --base_url=http://commerce.gestionx.cl/ --backend_frontname=admin --db_host=localhost --db_name=gestionx_commerce --db_user=gestionx_comuser --db_pass=C0MM3rc3Db --admin_firstname=Administrador --admin_lastname=Local [email protected] --admin_username=administrador --admin_password=4dm1nM4g3nt0 --language=es_CL --currency=CLP --timezone=America/Santiago But this does simply nothing. Command returns immediately with no error. I cannot use any installation method. Can you please tell me what might be happening here? Thanks Jaime
Reply
Ksenia Dobreva
November 30, 2015
Hey Jaime, this instruction is a bit outdated, it was valid before Magento 2 general availability release. Try installing php5-mcrypt and installing the package from Magento website https://www.magentocommerce.com/download Hope that helps!
Paolo
March 16, 2021
The article is unreadable! You must somehow structure the information in the article!
Reply
Vladimir Derachits
March 16, 2021
Sorry for having a problem with this article. It's quite outdated and we'll see what we can do to avoid confusion about this article in the future.
Leave your comment

Your email address will not be published

This blog was created with Amasty Blog Pro

This blog was created with Amasty Blog Pro

Loading