How to Install Magento 2 Via GitHub?

Jul 17th, 2024 6 min to read

Are you stuck with the manual installation process of Magento 2? Even seasoned developers can find it a daunting task to manage all the libraries and dependencies when installing Magento.

In this comprehensive guide, we’ll walk you through the steps to effortlessly install Magento via GitHub. Along with that, we’ll also provide you with solutions for common errors that you may face while installing Magento. Let’s start.

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

This section will cover two installation methods.

  1. Magento 2 Installation via GitHub with Sample Data
  2. Magento 2 Installation via GitHub without Sample Data

Both methods will begin by downloading the Magento 2 source code files from Github.

It is recommended to download the Magento 2 repository from official Github reps. For added convenience, you can also refer to a compiled list of downloadable Magento version files to quickly find your preferred version’s source code.

1. Magento 2 Installation via GitHub with Sample Data

After downloading Magento 2 files with sample data (via GitHub), here’s how you can install Magento.

Step 1: Go to the web server’s root directory, webroot (not Magento 2).

This is typically /var/www/html or a similar location on your server.

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

git clone git@github.com:magento/magento2-sample-data.git

Step 3: Later, navigate to the newly created magento2-sample-data directory. You can use the cd command in your terminal. (For example; cd magento2-sample-data)

Once you do that, 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"

This will create a new directory named magento2-sample-data inside your webroot directory.

Step 4: Next up, you need to set ownership and permissions for the Linux system:

chown -R :your_web_server_group_name
find . -type d -exec chmod g+ws {} \;

Replace: “your_web_server_group_name” with the actual group name used by your web server.

Step 5: Navigate to the var/ directory within your Magento 2 installation and run the following command to clear the cache:

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

Step 6: Finally, run these commands in your terminal to install the sample data:

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

And that’s all, you’ve successfully installed Magento with sample data.

Now, let’s check the process you need to follow when you wish to install Magento 2 via GitHub but without sample data.

2. Magento 2 Installation via GitHub without Sample Data

After downloading Magento 2 files without sample data (via GitHub), here’s the process to install Magento.

Step 1: Open your terminal application and create a new empty directory using this command:

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

or 

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

This will create a new directory named magento2 in your current directory.

Step 2: Navigate to the Magento 2 directory you just created. Run the following command to install the PHP dependencies:

This might take some time depending on your internet speed.

Step 3: Now, it’s time for you to install Magento 2.

You’ll need to provide your database credentials for this step.

Here I’m adding an example command assuming:

  • Magento install directory: magento2
  • Database host: localhost
  • Database name: magento
  • Database user: magento
  • Database password: your_password
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 \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=opensearch \
--opensearch-host=os-host.example.com \
--opensearch-port=9200 \
--opensearch-index-prefix=magento2 \
--opensearch-timeout=15

Step 4: Finally, Open your web browser and visit the URL you specified during installation (e.g., http://localhost/your-store-url/). You’ll see the Magento 2 installation wizard.

Lastly, you can follow the on-screen instructions to complete the setup process.

DONE! You’ve successfully installed Magento 2 without sample data.

Additional Notes:

  • Make sure you have Git and Composer installed on your server before proceeding.
  • Adjust file permissions on the Magento directory for your web server to function properly.

This is a basic installation process. You might need to configure additional settings depending on your specific needs. It’s suggested to have an experienced person by your side, you can always count on our Magento Experts to help you with the installation process.

Common Magento Install Errors: Fixes & Workarounds

Installing Magento 2 can sometimes run into errors.

So, in this section, here are some common issues that you may face when installing Magento 2 with a solution for each of them. Let’s start.

1. Permission Errors

  • Error: This is the most common type of error where you see a message about insufficient permissions during installation.
  • Solution: You see this error when you try to access a specific file or the Magento directory without sharing them the permissions to function. Check your server’s documentation and understand how to set file permissions. Later, grant ownership and write access to the Magento installation directory for the web server user.

2. PHP Version Compatibility

  • Error: A warning or fatal error during the installation process, indicating that the current PHP version does not meet the requirements for Magento.
  • Solution: Easy Magento typically requires a specific PHP version to work with, so do your research on which Magento version you’ve chosen and the PHP version that it is compatible with.

3. mod_rewrite Issues

  • Error: The installation process gets stuck or fails due to potential issues with mod-rewrite.
  • Solution: Magento relies on Apache’s mod_rewrite module to function. If it’s not configured, you’ll see the error. To fix it, you’ll need to refer to your server documentation and check for instructions.

4. Memory Limit Exhaustion

  • Error: You encounter errors showing insufficient memory.
  • Solution: Magento requires a certain amount of PHP memory for the installation process. To overcome this issue, you can increase the PHP memory limit to around a value like 2048M (2GB) or more in your php.ini file to meet Magento’s requirements.

5. Database Issues

  • Error: When you encounter errors relating to database connection or credentials.
  • Fix: To fix it, double-check the database credentials that you provide during installation to ensure they match your actual database configuration.

6. Missing PHP Extensions

  • Error: When running composer installs during installation, you might see error messages indicating missing extensions. These messages typically mention ext- followed by the extension name (e.g., ext-curl).
  • Solution: To solve this error, double-check if all the PHP extensions are installed and enabled. Common extensions required by Magento include PHP extensions like curl, gd, intl, mbstring, openssl, and pdo_mysql.

That was all about the common issues that you may face while installing Magento.

Last Words

I hope this information helps you seamlessly install Magento while helping you avoid potential errors.

If you need help installing Magento 2 or for your future adventures with Magento, our team of experts is here to help. Our range of Magento services includes:

Feel free to contact us, we are happy to help. 😀

Dhruvi Master
Speak your Mind

Post a Comment

Got a question? Have a feedback? Please feel free to leave your ideas, opinions, and questions in the comments section of our post! ❤️

* This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Grow your online business like 2,367 subscribers

    * This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
    envelope

    Thank You!

    We are reviewing your submission, and will be in touch shortly.