AlmaLinuxRHEL Based

How To Install Magento on AlmaLinux 10

Install Magento on AlmaLinux 10

Setting up a robust e-commerce platform requires careful planning and precise execution. Magento stands as one of the most powerful open-source e-commerce solutions available today, offering extensive customization capabilities and enterprise-grade features that have made it the preferred choice for thousands of online retailers worldwide. When paired with AlmaLinux 10, a stable and reliable RHEL-compatible distribution, you create a formidable foundation for your online business operations.

AlmaLinux 10 provides the perfect hosting environment for Magento installations, combining enterprise-level stability with cost-effective deployment options. This comprehensive guide will walk you through every step of installing Magento on AlmaLinux 10, from initial system preparation to final configuration and optimization. Whether you’re a system administrator, web developer, or business owner looking to establish a professional e-commerce presence, this tutorial provides the technical depth and practical insights needed for a successful deployment.

The installation process involves multiple components working in harmony: PHP runtime environment, database server, web server configuration, and the Magento application itself. Each component requires specific configuration to ensure optimal performance and security. By following this guide, you’ll establish a production-ready Magento installation that can scale with your business needs.

System Requirements and Prerequisites

Hardware Requirements

Before beginning the Magento installation on AlmaLinux 10, ensure your server meets the minimum hardware specifications. RAM requirements form the cornerstone of performance considerations, with 4GB serving as the absolute minimum for development environments, though 8GB or more is strongly recommended for production deployments.

The CPU requirements depend on expected traffic volume and concurrent user sessions. A dual-core processor handles basic installations adequately, but multi-core systems provide better performance under load. Storage considerations require at least 25GB of available disk space, with SSD storage preferred for database operations and faster page load times.

Network connectivity plays a crucial role in both installation and ongoing operations. Stable internet connectivity ensures smooth package downloads and future updates. Consider bandwidth requirements based on expected traffic patterns and media-rich product catalogs.

Software Prerequisites

AlmaLinux 10 server installation with root administrative access represents the foundation requirement. The system should be freshly installed with minimal packages to avoid potential conflicts during the Magento installation process.

PHP version compatibility demands careful attention, as Magento requires PHP 8.2 or later versions. The installation will involve multiple PHP extensions essential for Magento’s functionality, including database connectors, image processing libraries, and security modules.

Database server requirements specify MySQL 8.0 or MariaDB 10.4 as minimum versions, with MariaDB often preferred for its enhanced performance characteristics and open-source licensing model. The database server can run on the same system as the web server for smaller installations or on separate dedicated hardware for high-traffic deployments.

Web server selection typically involves choosing between Apache HTTP Server and Nginx. Apache offers broader compatibility and easier configuration for beginners, while Nginx provides superior performance under high concurrent loads. This guide focuses on Apache configuration for its widespread adoption and comprehensive documentation.

Initial Server Setup

Creating a dedicated system user for Magento operations enhances security by following the principle of least privilege. This user account will own Magento files and execute application processes, preventing potential security vulnerabilities associated with running web applications under root privileges.

Sudo privileges configuration allows the Magento user to perform necessary administrative tasks without requiring direct root access. Proper sudo configuration balances operational convenience with security requirements.

Basic security hardening steps include disabling unnecessary services, configuring SSH key authentication, and implementing fail2ban for automated intrusion prevention. These measures establish a secure foundation before installing web-facing applications.

Firewall configuration using firewalld ensures only necessary ports remain accessible from external networks. The standard configuration opens ports 80 (HTTP) and 443 (HTTPS) while restricting access to administrative services like SSH and database ports.

Installing and Configuring Dependencies

System Updates and Repository Setup

Begin the installation process by updating all existing packages on your AlmaLinux 10 system. This ensures compatibility with newly installed components and addresses any known security vulnerabilities:

sudo dnf update -y
sudo reboot

The EPEL (Extra Packages for Enterprise Linux) repository provides additional packages not included in the standard AlmaLinux repositories. Install EPEL to access a broader range of software packages:

sudo dnf install -y epel-release
sudo dnf update -y

The Remi repository offers updated PHP packages optimized for enterprise Linux distributions. Add the Remi repository to access PHP 8.4 and related extensions:

sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-10.rpm
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.4 -y

Verify repository installation and GPG key management by listing enabled repositories and confirming package signatures during installation. This verification step prevents potential security issues from compromised package sources.

PHP Installation and Configuration

Install PHP 8.4 along with all required extensions for Magento functionality. The comprehensive package list ensures compatibility with Magento’s core features and third-party extensions:

sudo dnf install -y php php-cli php-fpm php-mysqlnd php-opcache \
php-gd php-curl php-soap php-intl php-mbstring php-zip \
php-bcmath php-xml php-json php-sodium php-dom php-xmlwriter \
php-simplexml php-ctype php-iconv php-openssl

PHP configuration optimization requires editing the php.ini file to accommodate Magento’s resource requirements. Locate the configuration file and modify key settings:

sudo cp /etc/php.ini /etc/php.ini.backup
sudo nano /etc/php.ini

Essential PHP.ini modifications include:

memory_limit = 2G
max_execution_time = 1800
max_input_time = 1800
max_input_vars = 10000
post_max_size = 64M
upload_max_filesize = 64M
date.timezone = America/New_York
opcache.memory_consumption = 512
opcache.max_accelerated_files = 60000
opcache.consistency_checks = 0
opcache.validate_timestamps = 0
opcache.enable_cli = 1

Start and enable PHP-FPM service for optimal performance:

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Web Server Installation (Apache)

Install Apache HTTP Server and essential modules for Magento support:

sudo dnf install -y httpd mod_ssl mod_rewrite
sudo systemctl start httpd
sudo systemctl enable httpd

Configure Apache for Magento by creating a dedicated virtual host configuration. This approach maintains clean separation between different web applications and simplifies SSL certificate management:

sudo nano /etc/httpd/conf.d/magento.conf

Add the following virtual host configuration:

<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot /var/www/html/magento2
    
    <Directory /var/www/html/magento2>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog /var/log/httpd/magento_error.log
    CustomLog /var/log/httpd/magento_access.log combined
</VirtualHost>

Enable necessary Apache modules and restart the service:

sudo systemctl restart httpd

Configure firewall rules to allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Database Server Setup (MariaDB)

Install MariaDB server and client packages:

sudo dnf install -y mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the security installation script to configure initial database security settings:

sudo mysql_secure_installation

Follow the prompts to set a strong root password, remove anonymous users, disable remote root login, and remove test databases. These steps significantly improve database security.

Create a dedicated database and user account for Magento:

sudo mysql -u root -p

Execute the following SQL commands:

CREATE DATABASE magento2;
CREATE USER 'magento_user'@'localhost' IDENTIFIED BY 'secure_password_here';
GRANT ALL PRIVILEGES ON magento2.* TO 'magento_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Optimize MariaDB configuration for Magento workloads by editing the configuration file:

sudo nano /etc/my.cnf.d/server.cnf

Add performance optimizations under the [mysqld] section:

[mysqld]
innodb_buffer_pool_size = 1G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
query_cache_size = 64M
query_cache_type = 1
max_connections = 500

Restart MariaDB to apply configuration changes:

sudo systemctl restart mariadb

Installing Composer and Magento Dependencies

Composer Installation

Composer serves as PHP’s dependency manager and provides the recommended method for installing Magento. Download and install Composer globally:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Verify Composer installation:

composer --version

Configure Composer for optimal performance with Magento installations:

composer config --global repo.packagist composer https://packagist.org
composer global require hirak/prestissimo

Obtaining Magento

Create the web directory structure and set appropriate ownership:

sudo mkdir -p /var/www/html/magento2
sudo chown -R apache:apache /var/www/html/magento2
sudo chmod -R 755 /var/www/html/magento2

Navigate to the web root directory and download Magento using Composer. For Magento Community Edition:

cd /var/www/html/
sudo -u apache composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2

Authentication requirements necessitate Magento Marketplace credentials. Create an account at marketplace.magento.com and generate access keys for Composer authentication.

Pre-installation Checks

Magento includes built-in system requirement checking. Navigate to the Magento directory and run the readiness check:

cd /var/www/html/magento2
sudo -u apache php bin/magento setup:install --help

Verify file permissions comply with Magento requirements:

sudo find /var/www/html/magento2 -type f -exec chmod 644 {} \;
sudo find /var/www/html/magento2 -type d -exec chmod 755 {} \;
sudo chmod -R g+w /var/www/html/magento2/var /var/www/html/magento2/pub/media /var/www/html/magento2/pub/static /var/www/html/magento2/app/etc

Magento Installation Process

Command Line Installation

Execute the Magento installation using the command-line interface. This method provides more control over configuration options and better suits automated deployment scenarios:

cd /var/www/html/magento2
sudo -u apache php bin/magento setup:install \
--base-url=http://your-domain.com/ \
--db-host=localhost \
--db-name=magento2 \
--db-user=magento_user \
--db-password=secure_password_here \
--admin-firstname=Admin \
--admin-lastname=User \
--admin-email=admin@your-domain.com \
--admin-user=admin \
--admin-password=admin123! \
--language=en_US \
--currency=USD \
--timezone=America/New_York \
--use-rewrites=1

Installation parameters explanation:

  • --base-url: Your website’s primary URL
  • --db-*: Database connection parameters
  • --admin-*: Administrative user account details
  • --language: Default store language
  • --currency: Default currency setting
  • --timezone: Server timezone configuration
  • --use-rewrites: Enable URL rewriting for SEO-friendly URLs

The installation process typically takes 5-15 minutes depending on server performance. Monitor the output for any error messages indicating configuration issues.

Web-based Installation Alternative

Access the web installation wizard by navigating to your domain in a web browser. The setup wizard provides a user-friendly interface for users preferring graphical installation methods.

Follow the step-by-step wizard process:

  1. Readiness Check: Verify system requirements
  2. Add a Database: Configure database connection
  3. Web Configuration: Set base URLs and admin path
  4. Customize Your Store: Configure store details
  5. Create Admin Account: Set up administrative access
  6. Install: Execute the installation process

The web-based method offers similar functionality to command-line installation with visual progress indicators and error reporting.

Install Magento on AlmaLinux 10

Post-installation Configuration

Configure Magento cron jobs for automated maintenance tasks:

sudo -u apache crontab -e

Add the following cron job entries:

* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/html/magento2/var/log/magento.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/update/cron.php >> /var/www/html/magento2/var/log/update.cron.log
* * * * * /usr/bin/php /var/www/html/magento2/bin/magento setup:cron:run >> /var/www/html/magento2/var/log/setup.cron.log

Set Magento to production mode for optimal performance:

cd /var/www/html/magento2
sudo -u apache php bin/magento mode:set production
sudo -u apache php bin/magento cache:clean
sudo -u apache php bin/magento cache:flush

Web Server Configuration and Security

Apache Virtual Host Configuration

Create a comprehensive virtual host configuration optimized for Magento:

sudo nano /etc/httpd/conf.d/magento-ssl.conf

Add SSL-enabled virtual host configuration:

<VirtualHost *:443>
    ServerName your-domain.com
    DocumentRoot /var/www/html/magento2/pub
    
    SSLEngine on
    SSLCertificateFile /path/to/your/certificate.crt
    SSLCertificateKeyFile /path/to/your/private.key
    
    <Directory /var/www/html/magento2/pub>
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    <Directory /var/www/html/magento2/pub/media>
        AllowOverride None
        <IfModule mod_headers.c>
            Header always set X-Frame-Options SAMEORIGIN
        </IfModule>
    </Directory>
    
    ErrorLog /var/log/httpd/magento_ssl_error.log
    CustomLog /var/log/httpd/magento_ssl_access.log combined
</VirtualHost>

SSL/TLS Implementation

Install Let’s Encrypt Certbot for free SSL certificates:

sudo dnf install -y certbot python3-certbot-apache
sudo certbot --apache -d your-domain.com

Configure automatic certificate renewal:

sudo crontab -e

Add renewal cron job:

0 12 * * * /usr/bin/certbot renew --quiet

Security Hardening

Implement comprehensive security measures for production deployments:

# Set secure file permissions
sudo find /var/www/html/magento2 -type f -exec chmod 644 {} \;
sudo find /var/www/html/magento2 -type d -exec chmod 755 {} \;
sudo chmod 600 /var/www/html/magento2/app/etc/env.php

# Install and configure fail2ban
sudo dnf install -y fail2ban
sudo systemctl start fail2ban
sudo systemctl enable fail2ban

Create fail2ban configuration for Apache:

sudo nano /etc/fail2ban/jail.local

Add Apache protection:

[apache-auth]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/httpd/*error.log
maxretry = 3
bantime = 3600

[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/httpd/*access.log
maxretry = 6
bantime = 3600

Performance Optimization

PHP Performance Tuning

Configure OPcache for maximum performance:

sudo nano /etc/php.d/10-opcache.ini

Optimize OPcache settings:

opcache.enable=1
opcache.memory_consumption=512
opcache.interned_strings_buffer=64
opcache.max_accelerated_files=60000
opcache.revalidate_freq=0
opcache.save_comments=1
opcache.enable_cli=1

Configure PHP-FPM pool settings:

sudo nano /etc/php-fpm.d/www.conf

Optimize worker processes:

pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500

Database Optimization

Fine-tune MariaDB for Magento workloads:

sudo nano /etc/my.cnf.d/magento.cnf

Add Magento-specific optimizations:

[mysqld]
innodb_buffer_pool_size = 2G
innodb_log_file_size = 512M
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
query_cache_size = 128M
query_cache_limit = 2M
tmp_table_size = 64M
max_heap_table_size = 64M

Caching Strategies

Configure Redis for session and cache storage:

sudo dnf install -y redis
sudo systemctl start redis
sudo systemctl enable redis

Update Magento configuration to use Redis:

cd /var/www/html/magento2
sudo -u apache php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=127.0.0.1 --cache-backend-redis-db=0
sudo -u apache php bin/magento setup:config:set --session-save=redis --session-save-redis-host=127.0.0.1 --session-save-redis-log-level=3 --session-save-redis-db=1

Troubleshooting Common Issues

Installation Problems

PHP Extension Missing Errors: Verify all required extensions are installed:

php -m | grep -E 'curl|dom|gd|intl|mbstring|mysql|soap|xml|zip'

Install missing extensions individually:

sudo dnf install -y php-extension-name
sudo systemctl restart php-fpm httpd

Database Connection Failures: Test database connectivity:

mysql -u magento_user -p -h localhost magento2

Verify database permissions and firewall settings if connection fails.

File Permission Issues: Reset Magento file permissions:

cd /var/www/html/magento2
sudo find . -type f -exec chmod 644 {} \;
sudo find . -type d -exec chmod 755 {} \;
sudo chmod -R g+w var generated vendor pub/static pub/media app/etc

Memory Limit Exceeded: Increase PHP memory limits:

sudo sed -i 's/memory_limit = .*/memory_limit = 2G/' /etc/php.ini
sudo systemctl restart php-fpm

Runtime Issues

500 Internal Server Errors: Check Apache error logs:

sudo tail -f /var/log/httpd/error_log

Common causes include incorrect file permissions, PHP configuration errors, or missing Apache modules.

Blank Page Problems: Enable Magento error reporting:

cd /var/www/html/magento2
sudo -u apache php bin/magento deploy:mode:set developer

Check var/log directory for detailed error messages.

Admin Panel Access Issues: Verify admin URL and clear caches:

sudo -u apache php bin/magento info:adminuri
sudo -u apache php bin/magento cache:clean

Performance Issues

Slow Page Load Diagnosis: Enable Magento profiler:

cd /var/www/html/magento2
sudo -u apache php bin/magento dev:profiler:enable html

Monitor database slow query log:

sudo nano /etc/my.cnf.d/server.cnf

Add logging configuration:

slow_query_log = 1
slow_query_log_file = /var/log/mysql-slow.log
long_query_time = 2

Post-Installation Tasks and Maintenance

Essential Post-Installation Steps

Configure automated backups using custom scripts:

sudo nano /usr/local/bin/magento-backup.sh

Create backup script:

#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backups/magento2"
mkdir -p $BACKUP_DIR

# Database backup
mysqldump -u magento_user -p magento2 > $BACKUP_DIR/database_$DATE.sql

# File backup
tar -czf $BACKUP_DIR/files_$DATE.tar.gz /var/www/html/magento2

# Cleanup old backups (keep 7 days)
find $BACKUP_DIR -name "*.sql" -mtime +7 -delete
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete

Set up log rotation to prevent disk space issues:

sudo nano /etc/logrotate.d/magento

Configure log rotation:

/var/www/html/magento2/var/log/*.log {
    daily
    missingok
    rotate 7
    compress
    notifempty
    create 644 apache apache
}

Ongoing Maintenance

Establish regular update procedures for both Magento and AlmaLinux:

# Update system packages
sudo dnf update -y

# Update Magento (backup first!)
cd /var/www/html/magento2
sudo -u apache composer update
sudo -u apache php bin/magento setup:upgrade
sudo -u apache php bin/magento setup:di:compile
sudo -u apache php bin/magento setup:static-content:deploy

Configure monitoring using built-in system tools:

# Monitor system resources
sudo dnf install -y htop iotop nethogs

# Monitor Apache performance
sudo dnf install -y mod_status

Set up automated security updates:

sudo dnf install -y dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timer

Congratulations! You have successfully installed Magento. Thanks for using this tutorial for installing Magento eCommerce software on your AlmaLinux OS 10 system. For additional help or useful information, we recommend you check the official Magento website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button