How to Install Magento 2 via GitHub

If you’ve worked with Magento 2 before, you’ve probably noticed that many developers prefer installing it through GitHub rather than downloading the archive package. GitHub gives you direct access to the Magento source code, simplifies version management, and fits naturally into most development workflows.

Whether you’re setting up a fresh development environment, testing a specific Magento version, or starting a new project, installing Magento 2 via GitHub is a reliable approach. 

In this guide, we’ll walk through the complete installation process step by step using simple commands and explanations.

Prerequisites

Before starting the installation, make sure your server meets Magento’s requirements.

You should have:

  • PHP installed
  • Composer installed
  • MySQL or MariaDB database
  • Apache or Nginx web server
  • Git installed
  • Magento Marketplace authentication keys

You can verify the Git installation by running:

git --version

You can verify the Composer installation by running:

composer --version

Step-by-Step Guide to Install Magento 2 Using GitHub

Follow these steps to install Magento 2 from GitHub, configure dependencies, and complete the setup successfully on your server.

Step 1: Generate Magento Authentication Keys

Magento packages require authentication before downloading dependencies.

  1. Log in to your Magento account.
  2. Open Marketplace.
  3. Navigate to My Profile > Access Keys.
  4. Create a new access key if you do not already have one.

You will receive:

  • Public Key
  • Private Key

Keep them ready because Composer will ask for them later.

Step 2: Clone Magento 2 from GitHub

Navigate to your web root directory and clone the Magento repository.

git clone https://github.com/magento/magento2.git

Move into the Magento directory:

cd magento2

Step 3: Check out the Required Magento Version

By default, GitHub downloads the latest code branch.

To install a specific Magento version, first view available tags:

git tag

For example, to install Magento 2.4.8:

git checkout 2.4.8

You can replace the version number with the version you want to install.

Step 4: Install Magento Dependencies

Magento uses Composer to download all required packages.

Run:

composer install

During installation, Composer may ask for your Magento authentication keys.

Example:

Username: Public Key

Password: Private Key

After successful execution, all Magento dependencies will be downloaded.

Step 5: Create a Database

Log in to MySQL:

mysql -u root -p

Create a new database:

CREATE DATABASE magento2;

You can use any database name you prefer.

Step 6: Configure File Permissions

Set the correct file permissions before installation.

find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +

find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +

chmod u+x bin/magento

Proper permissions help avoid installation and deployment issues.

Step 7: Run Magento Installation Command

Now install Magento using the setup command.

Example:

php bin/magento setup:install \

--base-url=http://localhost/magento2 \

--db-host=localhost \

--db-name=magento2 \

--db-user=root \

--db-password=password \

--admin-firstname=Admin \

--admin-lastname=User \

[email protected] \

--admin-user=admin \

--admin-password=Admin123! \

--language=en_US \

--currency=USD \

--timezone=America/Chicago \

--use-rewrites=1

Replace the values with your own server and admin details.

Once completed, Magento will display a success message along with the Admin URL.

Step 8: Deploy Static Content

Generate static files for the storefront.

php bin/magento setup:static-content:deploy -f

This command creates CSS, JavaScript, and other frontend assets.

Step 9: Reindex Magento

Run indexing to update Magento data.

php bin/magento indexer:reindex

Step 10: Flush Cache

Clear Magento cache.

php bin/magento cache:flush

This ensures Magento loads the latest configuration and files.

Verify the Installation

Open your browser and visit: http://your-domain.com 

For the admin panel: http://your-domain.com/admin 

Use the admin username and password you entered during installation.

If both frontend and admin pages load correctly, your Magento installation is complete.

Common Issues During Installation

Here are some common installation issues and quick fixes to help you complete the setup without interruptions.

Composer Authentication Error

If Composer cannot download packages, verify that your Magento Marketplace access keys are correct.

Memory Limit Error

Increase PHP memory limit:

memory_limit = 2G

Then restart the web server.

Permission Errors

Make sure Magento directories have proper ownership and permissions.

Example:

chown -R www-data:www-data .

Replace www-data with your web server user if needed.

This method is commonly used by Magento developers and agencies working on custom projects.

Installing Magento 2 via GitHub is a straightforward process once your server is properly prepared. By cloning the Magento repository, installing dependencies with Composer, creating a database, and running the setup command, you can have a fully functional Magento store ready for development.

Sanjay Jethva

Article by

Sanjay 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...