Skip to content

Deployment Overview of Magento on Server

Prerequisites and Basic Requirements

The deployment requires a server running Ubuntu 22.04 (Jammy Jellyfish). The following system resources and software components are required for the application to function correctly:

  • Operating System: Ubuntu 22.04 LTS

  • Privileges: Root or sudo access is required for all installation steps.

  • PHP Version: 8.3

  • Database: MariaDB 10.6

  • Search Engine: OpenSearch 2.12.0 (with OpenSearch Dashboards)

  • Cache/Session Management: Redis

  • Package Manager: Composer

FQDN of the final panel on the hostkey.in domain

The application is accessible via a dynamically generated subdomain based on the server ID. The template for the Fully Qualified Domain Name (FQDN) is as follows:

Parameter Value
Prefix magento
Domain hostkey.in
Full template magento{Server_ID}.hostkey.in

File and Directory Structure

The application files and configuration are organized within the following directory structure:

  • Application Root: /var/www/magento

  • Apache Configuration: /etc/apache2/sites-available/

  • OpenSearch Configuration: /etc/opensearch/

  • Redis Configuration: /etc/redis/

  • SSL Certificates: /etc/letsencrypt/live/

Application Installation Process

The installation follows a multi-stage process involving package management, dependency resolution, and application setup:

  1. System Preparation: The system is updated, and necessary repositories (including the ppa:ondrej/php repository for PHP 8.3) are enabled.

  2. Dependency Installation: Essential packages including curl, unzip, gnupg2, and software-properties-common are installed via apt.

  3. PHP Environment Setup: PHP 8.3 is installed along with several required extensions: bcmath, xml, curl, gd, intl, dom, mysql, soap, zip, and mbstring.

  4. Composer Configuration: Composer is installed, and Magento-specific authentication keys are configured globally to allow the download of the project from the official repository.

  5. Project Creation: The Magento Open Source project is initialized in /var/www/magento using the command:

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

  6. Magento Installation: The application is configured via the bin/magento setup:install command, which sets up the database connection, admin credentials, and search engine settings (OpenSearch).

  7. Static Content Deployment: Frontend and adminhtml static content is generated using php bin/magento setup:static-content:deploy.

Access Rights and Security

Security is managed through strict file permissions and SSL encryption:

  • Web Server User: The application files are owned by the www-data user.

  • Permissions:

  • Files in directories such as var, generated, vendor, pub/static, pub/media, and app/etc are granted group write (g+w) permissions.

  • Directories within these paths are granted the setgid bit (g+ws) to ensure new files inherit the correct group ownership.

  • The bin/magento executable is granted execution permissions (u+x).

  • SSL/TLS: SSL certificates are managed via Certbot. The server is configured to automatically redirect all HTTP traffic to HTTPS.

Databases

The application uses MariaDB as its primary relational database management system.

  • Database Host: localhost

  • Database Name: magento

  • Database User: magento

  • Storage Location: Managed by the MariaDB service on the local filesystem.

Docker Containers and Their Deployment

This deployment utilizes several standalone services to support the application environment:

OpenSearch

  • Image/Package: OpenSearch 2.12.0 (installed via .deb)

  • Port: 9200

  • Configuration: Configured to listen on 127.0.0.1. Security plugins are disabled for local communication.

OpenSearch Dashboards

  • Image/Package: OpenSearch Dashboards 2.12.0 (installed via .deb)

  • Purpose: Provides a web interface for visualizing OpenSearch data.

Custom Scripts and Additional Setup

Several scripts and manual actions are performed to finalize the environment:

  • RabbitMQ Installation Script: An installation script (/root/install_rabbitmq.sh) is used to add official RabbitMQ repositories and install the rabbitmq-server if enabled.

  • Magento Post-Installation Configuration:

  • Two-Factor Authentication (2FA) for the admin panel is disabled via bin/magento module:disable.

  • The Magento cron system is installed using bin/magento cron:install.

  • The application cache is flushed after static content deployment and configuration changes.

Application Update Instructions

To update the main Magento application, perform the following steps:

  1. Navigate to the application directory:

    cd /var/www/magento
    

  2. Run the dependency update via Composer (if applicable) and then run the deployment commands to refresh the state:

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

Location of Configuration Files and Data

Component Path
Magento Application Code /var/www/magento
Apache VirtualHost Config /etc/apache2/sites-available/{prefix}{server_id}.{zone}.conf
OpenSearch Config /etc/opensearch/opensearch.yml
Redis Config /etc/redis/redis.conf

Available Ports for Connection

The following ports are utilized by the server:

  • 80 (HTTP): Used for initial connection and redirection to HTTPS.

  • 443 (HTTPS): Secure web traffic for the application.

  • 9200: OpenSearch API access (local).

Starting and Stopping the Application

The application relies on several system services. Use systemctl to manage them:

  • Apache Web Server:

  • systemctl restart apache2

  • MariaDB Database:

  • systemctl restart mariadb

  • Redis Cache:

  • systemctl restart redis

  • OpenSearch:

  • systemctl restart opensearch

Proxy Servers

The application uses Apache as a web server and reverse proxy. It is configured with mod_rewrite to handle SEO-friendly URLs and to enforce HTTPS redirection for all incoming requests. SSL certificates are managed via Certbot to ensure encrypted communication over port 443.

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