Getting Started with Magento 2

This lesson will take our first steps in installing and configuring the 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 well-known among merchants and developers and is still widely used for running eCommerce stores.

Magento 2 is the latest version of the Magento platform. It comes with a different set of functionality and is wrapped in 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

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 and information about it and where to get started.

Let’s go ahead and click the “Get Started with Open Source” button

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

There is a “Download Open Source” button at the end of the page, and the button leads to the Magento packages page.

This page 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. It 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.

This tutorial 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 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 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. The composer will create a project-community-edition directory and extract Magento project files into it.

It may take a few 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. The 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 .

We are ready to install the 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. An installation command 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 be 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 will study these parameters and other parameters that can be executed during the Magento 2 Open Source installation.

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

A new MySQL database is required before running the installation command.

CREATE DATABASE magento;

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

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

You can use Magento Admin URI to access Magento Admin.

Also, you may have to configure either Apache or Nginx web server virtual hosts file to access a local domain and access Magento 2 Open Source application via a 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.

Now, you have a fully functional Magento 2 Open Source application. You can observe different features available out-of-box. Once you are ready to take the development path, I will show you in the upcoming 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

Learn more about Magento 2 in the Magento 2 Beginner courses! This course is for developers who want to start developing with Magento 2. The course covers Magento 2 concepts and the architecture of the Magento 2 platform.

Leave a comment

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