Skip to content

Deployment Overview of Magento on Server

Prerequisites and Basic Requirements

The deployment requires a server running Ubuntu 22.04 (Jammy). The system must have root privileges or equivalent sudo access to install packages and configure services. A valid domain or subdomain under the hostkey.in zone is required for the FQDN.

The following system ports must be available for the application and its dependencies:

  • Port 80 (HTTP)

  • Port 443 (HTTPS)

  • Port 3306 (MariaDB)

  • Port 9200 (OpenSearch)

  • Port 6379 (Redis)

FQDN of the Final Panel

The final application interface is accessible via the Fully Qualified Domain Name (FQDN) following this format:

magento<Server ID>.hostkey.in:443

Where <Server ID> is the unique identifier of the host. The system is configured to use HTTPS exclusively for the final state, redirecting HTTP traffic to HTTPS.

File and Directory Structure

The application and its components are organized in the following directories:

  • Web Root: /var/www/magento/pub

  • Application Root: /var/www/magento

  • Apache Configuration: /etc/apache2/sites-available/magento<Server ID>.hostkey.in.conf

  • OpenSearch Configuration: /etc/opensearch/opensearch.yml

  • Redis Configuration: /etc/redis/redis.conf

  • Let's Encrypt Certificates: /etc/letsencrypt/live/magento<Server ID>.hostkey.in/

  • Composer Authentication: /root/.config/composer/auth.json

Application Installation Process

The Magento application is installed using the Composer package manager. The specific version deployed is magento/project-community-edition.

The installation involves the following steps:

  1. Installing the composer package from the Ubuntu repository.

  2. Configuring Magento repository credentials in Composer.

  3. Creating the project directory at /var/www/magento using the command:

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

  4. Running the Magento setup installation script with specific database and search engine parameters.

The installation command uses the following configuration:

  • Base URL: https://magento<Server ID>.hostkey.in/

  • Language: en_US

  • Currency: USD

  • Timezone: UTC

  • Admin Username: root

  • Search Engine: opensearch

Access Rights and Security

The web server runs under the www-data user and group. All files and directories within the Magento installation are owned by www-data.

Security configurations include:

  • Disabling Two-Factor Authentication (2FA) modules (Magento_AdminAdobeImsTwoFactorAuth, Magento_TwoFactorAuth).

  • Enforcing HTTPS redirection in the Apache virtual host configuration.

  • Configuring OpenSearch to disable its internal security plugin (plugins.security.disabled: true).

  • Setting Apache to AllowOverride All and Require all granted within the /var/www/magento/pub directory.

Databases

The application uses MariaDB version 10.6 for data storage. The database is hosted on localhost and accessed via the following credentials:

  • Database Name: magento

  • Database User: magento

  • Host: localhost

The database service is managed by systemd and is started automatically on boot.

Docker Containers and Their Deployment

This deployment does not utilize Docker containers. All services including the web server, database, cache, and search engine are installed directly on the host operating system using native package managers.

Proxy Servers

Apache HTTP Server is configured as the web server and reverse proxy.

  • Virtual Host: Configured to listen on port 80 and redirect all traffic to HTTPS on port 443.

  • SSL/TLS: Managed by Certbot using Let's Encrypt. Certificates are issued for the domain magento<Server ID>.hostkey.in.

  • Rewrite Rules: The mod_rewrite module is enabled to handle URL rewriting required by Magento.

The Apache configuration file is located at /etc/apache2/sites-available/magento<Server ID>.hostkey.in.conf.

Permission Settings

Permissions are set to ensure the web server can read and write necessary files while maintaining security:

  • Files: Group write permissions are added (g+w) to files in var, generated, vendor, pub/static, pub/media, and app/etc.

  • Directories: Group write and sticky bit (g+ws) are applied to directories in the same locations.

  • Ownership: All files and directories under /var/www/magento are owned by the www-data group.

  • Executables: The bin/magento script has user execute permissions (u+x).

Location of Configuration Files and Data

Critical configuration files are stored in standard Linux paths:

  • Apache Site Config: /etc/apache2/sites-available/magento<Server ID>.hostkey.in.conf

  • OpenSearch Config: /etc/opensearch/opensearch.yml

  • Redis Config: /etc/redis/redis.conf

  • Composer Auth: /root/.config/composer/auth.json

  • SSL Certs: /etc/letsencrypt/live/magento<Server ID>.hostkey.in/fullchain.pem

Available Ports for Connection

The following ports are configured and open for connections:

  • 80: HTTP (Redirects to HTTPS)

  • 443: HTTPS (Secure application access)

  • 3306: MariaDB (Local connection only)

  • 9200: OpenSearch (Local connection only, bound to 127.0.0.1)

  • 6379: Redis (Local connection)

Starting, Stopping, and Updating

Services are managed using systemd. The following commands are used to control the lifecycle of the installed services:

  • Apache:

    systemctl start apache2.service
    systemctl stop apache2.service
    systemctl restart apache2.service
    systemctl status apache2.service
    

  • MariaDB:

    systemctl start mariadb.service
    systemctl stop mariadb.service
    systemctl restart mariadb.service
    systemctl status mariadb.service
    

  • OpenSearch:

    systemctl start opensearch.service
    systemctl stop opensearch.service
    systemctl restart opensearch.service
    systemctl status opensearch.service
    

  • OpenSearch Dashboards:

    systemctl start opensearch-dashboards.service
    systemctl stop opensearch-dashboards.service
    systemctl restart opensearch-dashboards.service
    systemctl status opensearch-dashboards.service
    

  • Redis:

    systemctl start redis.service
    systemctl stop redis.service
    systemctl restart redis.service
    systemctl status redis.service
    

To update the Magento application code, use the Composer or Magento CLI tools within the /var/www/magento directory, followed by static content deployment:

php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×