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:
-
System Preparation: The system is updated, and necessary repositories (including the
ppa:ondrej/phprepository for PHP 8.3) are enabled. -
Dependency Installation: Essential packages including
curl,unzip,gnupg2, andsoftware-properties-commonare installed viaapt. -
PHP Environment Setup: PHP 8.3 is installed along with several required extensions:
bcmath,xml,curl,gd,intl,dom,mysql,soap,zip, andmbstring. -
Composer Configuration: Composer is installed, and Magento-specific authentication keys are configured globally to allow the download of the project from the official repository.
-
Project Creation: The Magento Open Source project is initialized in
/var/www/magentousing the command: -
Magento Installation: The application is configured via the
bin/magento setup:installcommand, which sets up the database connection, admin credentials, and search engine settings (OpenSearch). -
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-datauser. -
Permissions:
-
Files in directories such as
var,generated,vendor,pub/static,pub/media, andapp/etcare 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/magentoexecutable 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 therabbitmq-serverif 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:
-
Navigate to the application directory:
-
Run the dependency update via Composer (if applicable) and then run the deployment commands to refresh the state:
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.