Magento

Last change on 2023-11-21 • Created on 2023-11-21 • ID: KO-255A4

This tutorial explains how to install the free e-commerce management system Magento2. Magento provides online merchants with a flexible shopping cart system, as well as control over the look, content and functionality of their online store. It offers users powerful marketing, search engine optimization, and catalog-management tools.

Important note: This tutorial is designed for an installation on a Managed Server.
Since Elasticsearch is required as the search engine in order to be able to install and use Magento, the full functionality is not available for [web hosting] (https://www.hetzner.com/webhosting) products.

This is a 3rd party application. We do not provide Magento2 technical support, and we cannot guarantee that it will work properly. For Magento2 support, please see https://developer.adobe.com/commerce/docs/


Prerequisites

Required before installation:

More information on Composer and Elasticsearch is provided in the course of the guide.


Example terminology

  • Username: magenh
  • Database name: magento2
  • Database user: magentuser
  • Hostname / database host: <dediXXX.your-server.de>
  • Domain: <example.com>
  • Subdomain: <magento.example.com>

Install Magento2

Step 1 - Account and webserver configuration

Create an account and an installation directory, which will also be the document_root of your website.

  1. Log onto your account and navigate to konsoleH.
  2. Select an existing account or create a new one.
  3. Create a new directory in your public_html directory. Later, you will install Magento in this directory:
    magenh@dediXXX:~/public_html$ mkdir ./magento
  4. Set the newly created directory as document_root of your site ("Services" » "Server Configuration"). Change document_root

Step 1.1 - PHP configuration

Set the PHP version to a release between 7.4 and 8.1 (no warranty) and set the following values ("Services" » "PHP Configuration"):

  • allow_url_fopen = On
  • memory_limit = 512M
  • upload_max_filesize = 128M
  • max_execution_time = 3600

Step 2 - Database setup

Create the database for your Magento2 ecommerce:

  1. On konsoleH, navigate to "Services" » "Databases" » "MariaDB/MySQL".
  2. Select "Add" and assign a name to the database and the user. Create magento database

Step 3 - Installation of required software

In order to install Magento, you need the following software:

hos-dev needed!

  • Composer

    Switch back into your home directory:

    cd ~

    After you request hos-dev and it is installed, follow the instructions in our documentation for Composer.

    If Composer does not work after you downloaded it with brew, try:

    software uninstall composer
    php -d allow_url_fopen=On -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
    php -d allow_url_fopen=On composer-setup.php
    php -r "unlink('composer-setup.php');"
    echo alias composer=\"/usr/bin/php -d allow_url_fopen=On /usr/home/$USER/composer.phar\" >> ~/.bashrc
    source ~/.bashrc

    Check if it was successfully installed:

    composer -V
  • Elasticsearch

    You should request the process release "java" in advance, see elasticsearch.

    Before you install Elasticsearch, open port 9200 in the firewall for the service to run (konsoleH » "Services" » "Open Ports"). Configure the options as shown below: add firewall rule

    After you open the port, install Elasticsearch as described in Hetzner Docs.

Step 4 - Download Magento

Now that the prerequisites are installed, you can install Magento:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <YOUR-INSTALLATION-DIR>

Replace <YOUR-INSTALLATION-DIR> with your magento directory, or just a . if you are executing the command directly within the magento directory.

  1. Log into Adobe Marketplace
  2. Click on your profile name in the top right and select "My Profile"
  3. Click on "Access Keys" on the register "Marketplace"
  4. Select "Create A New Access Key". Give it a name and click "OK" Adobe Marketplace keys overview
  5. Log onto Adobe Marketplace.
  6. Click on your profile name in the top right and select "My Profile".
  7. Click on "Access Keys" on the register "Marketplace".
  8. Select "Create A New Access Key". Give it a name and click "OK". Adobe Marketplace keys overview
  9. In order to authenticate yourself use: Username = <public_key> and Password = <private_key>. Adobe Marketplace CLI auth

Step 5 - Install Magento

Run the following commands in the magento directory.

  1. Enable the Elasticsearch module
php bin/magento module:enable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch7}
  1. Run the installation command with customized options
php bin/magento setup:install \
--base-url='http://magento.example.com/' \
--db-host='dedixxx.your-server.de' \
--db-name='magento2' \
--db-user='magentuser' \
--db-password='<secret-password>' \
--admin-firstname='FNAME' \
--admin-lastname='LNAME' \
--admin-email='mail@example.com' \
--admin-user='admin' \
--admin-password='<secure-password>' \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch7 \
--disable-modules=Magento_TwoFactorAuth,Magento_AdminAdobeImsTwoFactorAuth

Replace the example values with your own data. You should also replace the value of '--admin-password' with a more secure password.

--disable-modules=Magento_TwoFactorAuth,Magento_AdminAdobeImsTwoFactorAuth is used to disable 2FA when logging into the admin panel. You can re-enabled it later.

You can find the configuration of the installation in <installation_dir>/app/etc/env.php:

<?php
return [
    'backend' => [
        'frontName' => 'admin_d43s'
    ],
...

Change the frontName value to any directory on your website where the admin panel is accessible: http://magento.example.com/admin

Further steps

If everything works as expected, you can now get started with Magento! Check if your website is available:

  • Frontend: http://magento.example.com/
  • Backend: http://magento.example.com/admin

    Username: admin
    Password: <secure-password>

This is how the admin page should look: Admin Log-In window

If you see a system message like "invalid indexers": Invalid Indexers Sys-Message

Execute this command:

php bin/magento indexer:reindex

Successfully installing Magento for your e-commerce venture can pave the way for a robust online store.

Remember to keep your installation maintained and up-to-date in order to prevent security gaps.

Table of Contents