4.1.8 Magento 2 Installation Guide

The Host Banner Magento

Magento 2 is a powerful CMS (Content Management System) and framework for building online stores of any scale. It is written in PHP, uses MySQL or MariaDB, supports Composer, and runs on any PHP-compatible web server — Apache, Nginx, or LiteSpeed.

This system is designed for professional eCommerce development: it supports multiple storefronts, currencies, and languages, integrates with payment gateways and shipping providers, and features a scalable architecture with a rich ecosystem of modules.

Magento 2 is appreciated for:

  • its modular structure and flexible extension system;
  • a powerful admin panel with analytics and reports;
  • flexible SEO, URL, and caching configuration;
  • built-in tools for REST and GraphQL API integration;
  • high performance and responsive design.

Important! Regularly update Magento 2 and installed plugins. This is essential to protect against vulnerabilities and ensure compatibility with new versions of PHP and MySQL. Always create a full backup of your website and database before updating.

Server Preparation

Requirements

  • An active Virtual or Dedicated server plan
  • CPU: at least 2 cores
  • RAM: minimum 4 GB (8 GB or more recommended)
  • SSD: 40 GB or more
  • OS — Ubuntu 22.04 / 24.04 LTS
  • PHP 8.2 or 8.3, MySQL 8.0 or MariaDB 10.6+
  • Root access or a sudo-enabled user

Environment variables

  • DOMAIN_NAME — your site domain name
  • DB_NAME, DB_USER, DB_PASSWORD — database credentials
  • ADMIN_EMAIL, ADMIN_USER, ADMIN_PASS — admin account details
  • MAGENTO_PATH — installation directory path
  • <PUBLIC>, <PRIVATE> – private and public Adobe Marketplace keys

Installation Magento 2 on server

Installing dependencies

Magento requires several PHP extensions and build/cache utilities.

sudo apt update && sudo apt install php8.2 php8.2-fpm php8.2-cli php8.2-curl php8.2-mbstring php8.2-xml php8.2-intl php8.2-bcmath php8.2-zip php8.2-soap php8.2-gd php8.2-mysql unzip git composer -y

After installation, make sure PHP-FPM is running:

sudo systemctl status php8.2-fpm

MySQL Configuration

Create a database and user for Magento:

sudo mysql -u root -p
CREATE DATABASE DB_NAME CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'DB_USER'@'localhost' IDENTIFIED BY 'DB_PASSWORD';
GRANT ALL PRIVILEGES ON DB_NAME.* TO 'DB_USER'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Downloading and Installing Magento 2

  1. Navigate to the directory where the site will be placed:

    cd /var/www && mkdir MAGENTO_PATH && cd MAGENTO_PATH
    
  2. Download the Magento distribution via Composer:

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

    On the first run, Composer will ask for your Adobe Marketplace credentials (they’re free).

  3. Run the installation command with your parameters:

    bin/magento setup:install \
    --base-url=https://DOMAIN_NAME/ \
    --db-host=localhost --db-name=DB_NAME --db-user=DB_USER --db-password=DB_PASSWORD \
    --admin-firstname=Admin --admin-lastname=User --admin-email=ADMIN_EMAIL \
    --admin-user=ADMIN_USER --admin-password=ADMIN_PASS \
    --language=ru_RU --currency=UAH --timezone=Europe/Kyiv --use-rewrites=1
    

Once completed, the installer will output the URL of your admin panel.

Nginx Configuration

Create a configuration file for your site:

mv nginx.conf.sample magento.nginx.conf 
/etc/nginx/sites-available/magento.conf
server {
    listen 80;
    server_name DOMAIN_NAME;
    set $MAGE_ROOT /var/www/MAGENTO_PATH;
    include $MAGE_ROOT/magento.nginx.conf;
}

Enable the configuration:

sudo ln -s /etc/nginx/sites-available/magento.conf /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Installation Magento 2 on server with control panel

Note: If your server is managed via ISPmanager, cPanel, or Plesk, install PHP and MySQL using the panel’s built-in tools instead of manual commands.

  1. Set the document root: in domain settings, point the web root to ~/www/MAGENTO_PATH/pub.
  2. Select PHP version: for Magento 2.4.6+ choose PHP 8.2 and enable extensions intl, mbstring, soap, bcmath, pdo_mysql, gd, zip, curl, xml.
  3. Create a database.
  4. Install via SSH in panel terminal: add your Adobe Marketplace keys in Composer and create the project:
 composer config -g http-basic.repo.magento.com <PUBLIC> <PRIVATE> \
 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition <MAGENTO_PATH>
  1. Connect a search engine: install Elasticsearch or OpenSearch (compatible version) locally on your VPS, or use a managed instance.
  2. Set up Cron via panel: add Magento cron jobs (usually every 1–5 minutes) under Cron.
  3. Check: run php bin/magento setup:upgrade, deploy:mode:set production, reindex, cache flush, static content deploy.

Configuring Magento 2 Additional Features

Configuration File

The main Magento configuration file is located at: /var/www/DOMAIN_NAME/cfg/connect.inc.php See more details in our guide.

SSL Setup

To enable HTTPS, use Let’s Encrypt or a commercial SSL certificate.

After installing SSL, update the base URL:

bin/magento setup:store-config:set --base-url-secure=https://DOMAIN_NAME/
bin/magento cache:flush

Performance Optimization

bin/magento deploy:mode:set production
bin/magento cache:enable
bin/magento indexer:reindex

File and Permission Setup

sudo chown -R www-data:www-data /var/www/MAGENTO_PATH
sudo find /var/www/MAGENTO_PATH -type d -exec chmod 755 {} \;
sudo find /var/www/MAGENTO_PATH -type f -exec chmod 644 {} \;

Verifying Installation

  1. Open https://DOMAIN_NAME in your browser — the store’s homepage should load.
  2. The admin panel URL (shown at the end of setup) will look like: https://DOMAIN_NAME/admin_abcdef/
  3. Log in with your admin credentials.
  4. In the admin panel, go to System → Cache Management and ensure all cache types are enabled.
Common Errors
Error Cause Solution
No search / installation stops at search engine requirement Since Magento 2.4+, MySQL search is deprecated Install and configure Elasticsearch or OpenSearch (compatible version), then reindex.
404 / missing static files, admin without CSS Nginx root not pointing to pub/ or sample config ignored Set root to …/pub and include $MAGE_ROOT/magento.nginx.conf as required by Adobe.
502 Bad Gateway (PHP) Wrong PHP-FPM socket or port Check fastcgi_pass, restart PHP-FPM and Nginx; use the official config template as a base.
Blank admin / “cannot write to var…” Incorrect Magento directory ownership or permissions Grant web server group RW permissions on var, pub, generated, app/etcofficial guide
Indexing, email, sitemap don’t run automatically Magento cron jobs not configured Add Magento crontab and verify execution via CLI or panel.
PHP / extension version conflict PHP version or module unsupported by current release Check system requirements for your Magento branch and update environment or modules.