Skip to main content

Magento 2

Magento 2 Open Source

Version: 2.4.6
Operating System: Ubuntu 22.04
Category: E-commerce

Description

Magento is a leading open-source e-commerce platform. It offers users comprehensive control over the functionality, look, and content of their online stores, ensuring a seamless shopping experience. Magento provides numerous robust tools, including marketing, SEO, and catalog management features, making it highly customizable and efficient.

Included Software

SoftwareVersion
Magento Open Source2.4.6
PHP8.1
Composer2.5.8
Elasticsearch7.17.10
Varnish6.4.0
Apache2.4.41
MySQL8.0.33
Certbot0.40.0
Redis5.0.7
Postfix3.4.13

Getting Started

Before installation, ensure you have an account and authentication keys from Magento Marketplace.

Firewall Configuration

Allow the following ports:

  • SSH (port 22, rate-limited)
  • HTTP (port 80)
  • HTTPS (port 443)

Initial Setup

Upon initial connection via SSH as the ubuntu user, a setup script will automatically run. Follow prompts:

  • Enter your registered domain/sub-domain (without www or http/s).
  • Provide your Magento admin email address, username, and a secure password (minimum 6 characters with at least one digit and uppercase letter).
  • Choose whether to install SSL using Let’s Encrypt.

Note: Your domain must have DNS A records pointing to your server's IP before enabling SSL.

SSL Configuration

You can configure SSL immediately or later by running:

chmod +x /opt/ssl_config/ssl.sh && /opt/ssl_config/ssl.sh

Let’s Encrypt is recommended for secure HTTPS.

Magento Installation

Follow on-screen prompts to download and install Magento 2, optionally installing sample data.

  • Magento URL: http://your-domain.com
  • Magento Admin URL: http://your-domain.com/admin

Database Information

  • MySQL root password: /root/.mysql_root_password
  • Magento database details: /root/.magento_database_details

Connect to MySQL:

mysql -u root -p
# Enter password from /root/.mysql_root_password

Magento Authentication Keys

Update Magento authentication keys in /var/www/.config/composer/auth.json:

{
"http-basic": {
"repo.magento.com": {
"username": "$PUBLIC_KEY",
"password": "$PRIVATE_KEY"
}
}
}

Replace $PUBLIC_KEY and $PRIVATE_KEY with your actual keys.

Custom Setup Recommendations

Apache Virtual Hosts

Create dedicated virtual host files for each domain to simplify management:

  • Create a directory for your domain in /var/www.
  • Create corresponding virtual host file in /etc/apache2/sites-available.

SSL Certificate via Certbot

Ensure these DNS records are configured:

  • A record for your domain (e.g., example.com) pointing to your server’s IP.
  • A record for the www subdomain (e.g., www.example.com) pointing to your server’s IP.

Generate SSL certificate:

sudo certbot --apache -d example.com -d www.example.com

Allow HTTPS traffic (port 443) through your firewall. Optionally, deny HTTP (port 80) afterward for enhanced security.

Postfix Email Setup

Set a valid hostname:

hostnamectl set-hostname your.hostname.com

Update hostname in /etc/postfix/main.cf:

myhostname = your.hostname.com

Restart Postfix:

systemctl restart postfix

Test outgoing email:

echo "Postfix test" | mail -s "Subject" test@gmail.com

Note: Initially, emails may land in spam due to IP reputation. Reputation improves with consistent usage.

Important Paths

  • Web root directory: /var/www/html
  • Magento admin panel: http://your-domain.com/admin

Following these steps ensures a robust and secure Magento 2 installation ready for customization and deployment.