Magento 2 Development Workshop Learn More

Magento 2 for Beginners

10 lessons

Getting Started with Magento 2

Getting Started with Magento 2

In this lesson we are going to learn one of the leading e-commerce platforms called Magento 2. We are going to take our first steps installing and configuring Magento Open Source edition. It will allow us to observe Magento 2 Open Source functionality and start developing custom functionality.

Magento platform comes in different versions and editions. Magento 1 is very known among merchants and developers. It is still widely used for running e-commerce stores.

Magento 2 is the latest version of the Magento platform. It comes as a different set of functionality and wrapped in as a Magento 2 Open Source, Magento 2 Commerce on-prem and Magento 2 Commerce Cloud.

Only Magento 2 Open Source is available for us, developers or business owners, to install and use the platform without additional fees.

We are going to work with Magento 2 Open Source edition which is available for our installation purposes for free.

Before we begin

In order to follow the tutorial you have to have an environment with the following tools:

  • PHP 7.2+
  • Composer Package Manager
  • MySQL 5.7
  • Apache 2 or Nginx

Where to find Magento 2 Open Source?

Magento 2 Open Source can be found on the official Magento website. Navigate to Magento.com -> Community -> Community page you will find a Get Open Source link to the Magento Open Source landing page as well as information about it and where to get started.

Magento Open Source

Let's go ahead and click "Get Started with Open Source" button

Magento 2 Open Source capabilities and features in comparison to Magento 2 Commerce.

Built-in Features Magento 2 Open Source Magento 2 Commerce
Integrated Checkout, Payment, and Shipping Yes Yes
Mobile Optimized Shopping Yes Yes
Global Selling Yes Yes
Catalog Management Yes Yes
Extended Functionality via App Marketplace Yes Yes
Instant Purchase Yes Yes
Site Search Yes Yes
Business Intelligence Dashboards No Yes
B2B Functionality No Yes
Advanced Marketing Tools No Yes
Content Staging and Preview No Yes
Customer Loyalty Tools No Yes
WYSIWYG Page Builder No Yes
Visual Merchandising No Yes

There is a "Download Open Source" button at the end of the page. The button leads to the Magento packages page.

On this page, we can find different versions and releases, security patches, migration tools and additional patches you may download and install when these packages are released and available.

Installing with Composer

We may install Magento 2 Open Source using Composer Package Manager. I assume that you are familiar with a Composer Package Manager. This is a dependency management software that Magento 2 Open Source and Magento 2 Commerce editions use to manage platform dependencies.

We can download the latest version of the Magento 2 Open Source edition as a ZIP/Archive package directly from the Download page.

In this tutorial, I will show you how to install Magento 2 Open Source edition via Composer Package Manager.

Click on the "Get Started" button inside the "Download with Composer" section.

Magento Metapackage

This page provides the Magento Metapackage which we can use in order to install the latest Magento 2 Open Source edition.

Copy the following command to start with the composer installation.

Magento 2 Open Source

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

I assume that you have the latest PHP and Composer Package Manager installed on your local environment and you can follow the tutorial without interruption.

Navigate to your web server document root and paste the installation command into the command line.

This command will search for the latest Magento 2 Open Source edition inside the repository we have specified in the --repository parameter in my case it is Magento Open Source version 2.3.3. Composer will create a project-community-edition directory and extract Magento project files into it.

It may take a couple of minutes to download all Magento 2 Open Source project dependencies.

As a result, we have a new project-community-edition directory created where all Magento project files are located.

Navigate to the project-community-edition directory and observe the installed files.

cd project-community-edition/
ls -la .

Setting File Permissions

For Magento 2 Open Source project we have to set proper file permissions. Magento Installation page provides a set of commands which we have to execute to set permissions for files and directories of a Magento 2 Open Source project.

Let's copy and execute the following commands in the Magento project directory:

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

You may also need to execute one more command in the Magento project directory if your web server user is configured to run as part of a www-data group.

chown -R :www-data .

Alright, now we are ready to install Magento 2 Open Source edition.

Install Magento 2 Open Source

There are two ways to install the Magento 2 Open Source edition:

  • Command line
  • Web Setup Wizard

The fastest and easiest way to install Magento 2 Open Source is to do it via a command line. There is an installation command which can be used to install Magento 2 Open Source.

Let's copy the installation command:

bin/magento setup:install \
--base-url=http://magento2ce.magemastery.com \
--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

Please, don't afraid about all these parameters which have to be specified for a bin/magento setup:install command. In the upcoming lessons of the Magento 2 for Beginners course, we are going to study these parameters as well as other parameters that can be executed during the Magento 2 Open Source installation.

For your installation, make sure to double-check and update if necessary --base-url, --database-name, --database-password and --database-user.

A new MySQL database is required prior to running the installation command.

CREATE DATABASE magento;

Paste and run the installation command from the Magento project directory.

We may observer in a terminal two success messages after the successful installation.

Magento Open Source

You can use Magento Admin URI to access to Magento Admin.

Also, you may have to configure either Apache or Nginx web server virtual hosts file in order to access a local domain and access Magento 2 Open Source application via browser.

As for the reference, here is the example of the hosts file with the local domain name:

127.0.0.1 magento2ce.magemastery.com

And, Apache 2 httpd-vhosts.conf file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot "/Users/pronko/www/videos/tutorials/project-community-edition"
    ServerName magento2ce.magemastery.com
    ErrorLog "/usr/local/var/log/httpd/magento.com-error_log"
    CustomLog "/usr/local/var/log/httpd/magento.com-access_log" common
</VirtualHost>

Navigate to the http://magento2ce.magemastery.com link in a browser.

It may take a while to open a home page for the first time.

Magento 2 Open Source

Now, you have a fully functional Magento 2 Open Source application. You can observe different features available out-of-box and once you are ready to take the development path I will show you in the upcoming lessons of the Magento 2 for Beginners how to perform development in Magento 2.

So what have we learned?

  • We have learned about Magento 2 platform and particularly Magento 2 Open Source edition
  • We discussed where to find a Magento Metapackage
  • Magento 2 Open Source installation with Composer Package Manager
  • How to access newly installed Magento 2 Open Source via the browser

Next Lesson

In the next lesson, we are going to learn the Magento 2 Open Source project's structure and what files and directories are available for the development purposes.

Next Steps

Subscribe to the Mage Mastery newsletter to hear first about new lessons and courses.