How to Install Magento 2 and Verify Installation?

Install magento 2

Installing Magento 2 software could be challenging.

You can install Magento 2 with this super simplified step by step guide.

Note: For Magento 2.4 Installation with Command Line Method, check this guide.

How to Install Magento 2?

I’ve divided the installation into 3 phases:

  1. Requirements,
  2. Installation, and
  3. Post-installation

1. Requirements

  • You’re not on shared hosting and have your own Magento server.
  • Your OS is either Ubuntu or CentOS.
  • Everything is on one host (web server, database)
  • Install via composer create-project.
  • You’re installing to the magento2 subdirectory under your web server’s docroot (path: /var/www/html/magento)

Read more about Magento Requirements.

2. Installation

Now that you have ensured all the requirements, here’s how you can install Magento 2 and get your hands on the powerful Magento software:

Method to do Magento 2 Installation:

2.1. Install Magento 2 via Composer

Composer: A tool for dependency management in PHP.

Get the composer software by following these commands:

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

Note: In the installation, Magento core code is also stored under /vendor directory and updating is possible through Magento admin.

Step 1: Get Authentication Keys

You need authentication keys to get started which you can get by:

  • Login to Magento account > Go to “My Access Keys” > Enter “Name” and generate a new set of keys.
  • Know more about authentication keys here.

Enter this command:

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

Your public key is the username and private key is password.

Step 2: Go to Setup Wizard > Click on Install

Step 3: To install sample data:

Go to your Magento 2 root directory via terminal > run following commands

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

This will update your composer.json file and install sample data. If you see “Please re-run Magento compile command”, enter the following command:

php bin/magento setup:di:compile

2.2. Install via GitHub

1. Clone Magento repo from here or simply download it.

2. Create empty directory and run:

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

3. After deploying, run:

composer install

4. Now after installing Magento 2, the setup will look like:

php -f bin/magento setup:install -base-url =https://m2.loc/2.07/github/
--backend-frontname=admin
--db-host=localhost --db-name=m2git --db-user=root --db-password= xyz
--admin-firstname=Magento
--admin-lastname=User [email protected] --admin-user=admin
--admin-password=admin123
--language=en_US --currency=USD --timezone=India/Delhi -use-rewrites=1

Note: change your base-url, db-name, db-password, admin-email, admin-password to match the setup.

To install sample data:

1. Run git clone [email protected]:magento/magento2-sample-data.git in your web root.

2. Go to the cloned directory and execute the following command to create symlinks to your M2 installation:

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

For ownership and permissions (on Linux), follow these commands:

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

3. To clear cache or static files, follow:

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

4. For installing sample data, follow these commands:

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

After this, you’ll have sample data installed.

2.3. Install Magento 2 via Command line

Follow these commands to install Magento 2 via command line:

php /var/www/html/magento2/bin/magento setup:install --base-url=https://192.0.2.5/magento2/ 
--db-host=localhost --db-name=magento --db-user=magento --db-password=magento 
--admin-firstname=Magento --admin-lastname=User [email protected] 
--admin-user=admin --admin-password=admin123 --language=en_US 
--currency=USD --timezone=America/Chicago --use-rewrites=1

Wherein,

  • Database name is Magento
  • Username and password are both Magento
  • Properties of Magento administrator:
  • First name is Magento and the last name is User
  • Username is Admin and password is admin@123
  • E-mail address is [email protected]
  • Default language is en_US (US English)
  • Currency is USD by default.
  • Default time zone is India (Delhi)

Note: Magento software will be installed in the /var/www/html/magento2 directory and your storefront URL will be: https://103.90.240.1/magento2/

Replace 103.90.240.1 with your IP address

2.4. Install Magento 2 using Web Setup Wizard

Note: This method has been removed from Magento 2.4 version.

Follow these steps to run the Web Setup Wizard:

1. Open this URL in your browser: https://103.90.240.1/magento2/setup

Note: The Magento software will be installed in the magento2 directory relative to the web server docroot and your storefront URL will be https://103.90.240.1/magento2/

Replace 103.90.240.1 with your IP address.

2. At the welcome page > Agree and Setup Magento

magento 2 install1 Install Magento 2

3. Click Start Readiness check to verify your system is ready to install Magento 2 software.

4. Click “Next” if readiness check passes.

check readiness Install Magento 2

5. Check Readiness check issues if it fails.

6. “Add a Database” to set up your Magento database.

install magento 2 step2 Install Magento 2

7. With web configuration, you can enter the storefront and Magento Admin URLs.

8. You can enter a default store currency, language, and time zone by clicking on “Customize Your Store”.

9. Create a “Admin Account” to set up a Magento administrator and perform all the required actions.

Install Magento 2 setup wizard

10. To install, click on “Install Now”.

And there you go!

3. Post Installation: Is Magento 2 Installed Correctly?

3.1 Verifying the Magento 2 Storefront

If you’ve installed Magento 2 for URL is https://www.yourwebsitename.com, then open this in a browser. If you see the following storefront page, the installation was successful.

magento 2 install success storefront

3.2 Verifying the Magento Admin

  • Go to the Magento in a web browser.

For example, https://www.yourwebsitename.com/ admin_magento2 where https://www.yourwebsitename.com/ is your Magento installation base URL and the Admin URI is admin_magento2.

  • Log in as a Magento Admin.

You see the following page, it means the Magento 2 is installed successfully.

Install Magento 2
  • If there’s some problem with graphics, check here.
  • If you get a 404 error or similar error, check for solutions here.

Wrapping Up

In this simplified guide, I tried to keep every step as simple as possible. So you can easily install Magento 2 on your server.

However, if there is any doubt at any steps, leave it in comment box.

If you are looking for Magento 2 hosting, ServerGuy offers complete Managed Magento Hosting Solutions with 10 times faster, secure, and reliable hosting.

Latest Magento Tips, Guides, & News

Stay updated with new stuff in the Magento ecosystem including exclusive deals, how-to articles, new modules, and more. 100% Magento Goodness, a promise!

1 thought on “How to Install Magento 2 and Verify Installation?”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top

We can help you. Right now.

Fast growing merchants depend ServerGuy for high-performance hosting. Experience counts. Let's get started.

Talk to a sales representative

USA / Worldwide

+1.714.2425683

India

+91.9852704704

Core Web Vitals Book COver

Is your website ready for Core Web Vitals?

Take this FREE book with you and optimize your store for speed.

Learn all about new Google new ranking factors and get that top ranking.