E-Commerce Platform

    Deploy Magento on RamNode VPS

    Magento (Adobe Commerce) is a powerful, feature-rich e-commerce platform trusted by thousands of merchants worldwide. Deploy a production-ready Magento installation on RamNode VPS hosting with Nginx, MySQL, Elasticsearch, and Redis for optimal performance.

    Ubuntu 24.04 LTS
    MySQL 8.0 + Redis
    Elasticsearch 8.x
    ⏱️ 45-60 minutes

    What This Guide Covers

    Server Components:

    • • LEMP stack (Linux, Nginx, MySQL, PHP)
    • • Elasticsearch 8.x for catalog search
    • • Redis for caching and sessions
    • • SSL/TLS with Let's Encrypt
    • • Optional Varnish for full-page caching

    Optimization & Security:

    • • Performance tuning strategies
    • • Production mode configuration
    • • Security hardening measures
    • • Backup strategies and maintenance
    • • Troubleshooting common issues

    Prerequisites & Server Requirements

    Magento 2.4.x has specific system requirements. Choose the right RamNode VPS plan based on your store size:

    Store SizeRAMvCPUsStorageRamNode Plan
    Small (< 1,000 SKUs)4 GB2 cores50 GB SSDPremium KVM 4GB
    Medium (1,000-10,000 SKUs)8 GB4 cores100 GB SSDPremium KVM 8GB
    Large (10,000+ SKUs)16 GB6 cores200 GB SSDPremium KVM 16GB
    Enterprise32 GB+8+ cores400 GB+ SSDPremium KVM 32GB

    ⚠️ Note: For production stores with high traffic, start with the 8GB plan minimum. Magento requires significant resources during indexing and cache warming.

    Software Requirements

    • • Ubuntu 24.04 LTS (recommended)
    • • Nginx 1.24+
    • • PHP 8.2 with required extensions
    • • MySQL 8.0.33+
    • • Elasticsearch 8.11+
    • • Redis 7.2+
    • • Composer 2.6+

    Before You Begin

    • • RamNode VPS with Ubuntu 24.04 LTS
    • • Root or sudo access
    • • Domain name pointed to server IP
    • • Adobe Commerce Marketplace account
    • • SSH client for remote access
    2

    Initial Server Setup

    Connect to your RamNode VPS and perform essential system configuration:

    Connect and Update System
    ssh root@your_server_ip
    
    # Update package lists and upgrade installed packages
    apt update && apt upgrade -y
    
    # Install essential utilities
    apt install -y curl wget gnupg2 software-properties-common \
    apt-transport-https ca-certificates lsb-release unzip git

    Configure Timezone
    # Set timezone (adjust to your location)
    timedatectl set-timezone America/New_York
    
    # Generate and set locale
    locale-gen en_US.UTF-8
    update-locale LANG=en_US.UTF-8
    3

    Installing the LEMP Stack

    The LEMP stack (Linux, Nginx, MySQL, PHP) forms the foundation for running Magento:

    Install Nginx

    Install and Start Nginx
    # Install Nginx
    apt install -y nginx
    
    # Start and enable Nginx
    systemctl start nginx
    systemctl enable nginx
    
    # Verify installation
    nginx -v

    Install MySQL 8.0

    Install MySQL Server
    # Install MySQL Server
    apt install -y mysql-server
    
    # Start and enable MySQL
    systemctl start mysql
    systemctl enable mysql
    
    # Secure the installation
    mysql_secure_installation
    Create Magento Database and User
    # Log into MySQL
    mysql -u root -p
    
    # Create database and user
    CREATE DATABASE magento CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    CREATE USER 'magento'@'localhost' IDENTIFIED BY 'your_secure_password';
    GRANT ALL PRIVILEGES ON magento.* TO 'magento'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

    Install PHP 8.2

    Install PHP with Extensions
    # Add PHP repository
    add-apt-repository ppa:ondrej/php -y
    apt update
    
    # Install PHP 8.2 with required extensions
    apt install -y php8.2-fpm php8.2-cli php8.2-common \
    php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-curl \
    php8.2-gd php8.2-imagick php8.2-intl php8.2-mbstring \
    php8.2-opcache php8.2-soap php8.2-zip php8.2-bcmath \
    php8.2-sodium php8.2-xsl
    
    # Verify installation
    php -v

    4

    Installing Elasticsearch

    Elasticsearch is required for Magento 2.4+ catalog search functionality:

    Add Elasticsearch Repository
    # Import GPG key
    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | \
    gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
    
    # Add repository
    echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] \
    https://artifacts.elastic.co/packages/8.x/apt stable main" | \
    tee /etc/apt/sources.list.d/elastic-8.x.list
    
    apt update
    Install and Configure Elasticsearch
    # Install Elasticsearch
    apt install -y elasticsearch

    Configure for Magento by editing /etc/elasticsearch/elasticsearch.yml:

    Elasticsearch Configuration
    cluster.name: magento-cluster
    node.name: magento-node-1
    network.host: 127.0.0.1
    http.port: 9200
    xpack.security.enabled: false
    Start Elasticsearch
    # Start and enable Elasticsearch
    systemctl daemon-reload
    systemctl start elasticsearch
    systemctl enable elasticsearch
    
    # Verify installation
    curl -X GET 'http://localhost:9200'

    5

    Installing and Configuring Redis

    Redis dramatically improves Magento performance by caching sessions, full-page cache, and application cache in memory:

    Install Redis
    # Install Redis
    apt install -y redis-server
    
    # Verify installation
    redis-server --version

    Edit /etc/redis/redis.conf with optimizations:

    Redis Configuration
    # Bind to localhost only
    bind 127.0.0.1
    
    # Set password (recommended)
    requirepass your_redis_password
    
    # Memory management
    maxmemory 512mb
    maxmemory-policy allkeys-lru
    
    # Persistence (disable for pure caching)
    save ""
    appendonly no
    
    # TCP keepalive
    tcp-keepalive 300
    Start Redis
    # Restart and enable Redis
    systemctl restart redis-server
    systemctl enable redis-server
    
    # Test connection
    redis-cli -a your_redis_password ping

    Redis Database Layout for Magento

    DatabasePurposeDescription
    0Default/Backend CacheConfiguration, layouts, blocks
    1Page CacheFull page cache storage
    2Session StorageCustomer sessions
    6

    Installing Composer

    Composer is required to install Magento and manage its dependencies:

    Install Composer
    # Download Composer installer
    curl -sS https://getcomposer.org/installer | php
    
    # Move to system path
    mv composer.phar /usr/local/bin/composer
    
    # Verify installation
    composer --version
    
    # Switch to magento user
    su - magento
    
    # Configure Composer authentication
    composer config --global http-basic.repo.magento.com \
    <public-key> <private-key>

    💡 Note: Obtain your authentication keys from the Adobe Commerce Marketplace at marketplace.magento.com. Navigate to My Profile → Access Keys to generate or view your keys.

    7

    Magento Installation

    Install Magento using Composer and run the setup wizard:

    Create Installation Directory
    # Create web root directory
    mkdir -p /var/www/magento
    chown -R magento:www-data /var/www/magento
    chmod -R 755 /var/www/magento
    
    # Switch to magento user
    su - magento
    cd /var/www/magento
    Download Magento via Composer
    # Create Magento project (Open Source edition)
    composer create-project --repository-url=https://repo.magento.com/ \
    magento/project-community-edition=2.4.7 .
    
    # For Adobe Commerce (paid version), use:
    # composer create-project --repository-url=https://repo.magento.com/ \
    #     magento/project-enterprise-edition=2.4.7 .
    Set File Permissions
    # Set correct ownership
    cd /var/www/magento
    find var generated vendor pub/static pub/media app/etc -type f \
    -exec chmod g+w {} + 2>/dev/null
    find var generated vendor pub/static pub/media app/etc -type d \
    -exec chmod g+ws {} + 2>/dev/null
    chown -R magento:www-data .
    chmod u+x bin/magento
    Run Magento Setup
    bin/magento setup:install \
    --base-url=https://yourdomain.com \
    --db-host=localhost \
    --db-name=magento \
    --db-user=magento \
    --db-password='your_db_password' \
    --admin-firstname=Admin \
    --admin-lastname=User \
    --admin-email=admin@yourdomain.com \
    --admin-user=admin \
    --admin-password='SecureAdminPass123!' \
    --language=en_US \
    --currency=USD \
    --timezone=America/New_York \
    --use-rewrites=1 \
    --search-engine=elasticsearch8 \
    --elasticsearch-host=localhost \
    --elasticsearch-port=9200 \
    --session-save=redis \
    --session-save-redis-host=127.0.0.1 \
    --session-save-redis-port=6379 \
    --session-save-redis-db=2 \
    --session-save-redis-password='your_redis_password' \
    --cache-backend=redis \
    --cache-backend-redis-server=127.0.0.1 \
    --cache-backend-redis-port=6379 \
    --cache-backend-redis-db=0 \
    --cache-backend-redis-password='your_redis_password' \
    --page-cache=redis \
    --page-cache-redis-server=127.0.0.1 \
    --page-cache-redis-port=6379 \
    --page-cache-redis-db=1 \
    --page-cache-redis-password='your_redis_password'

    ⚠️ Note: Save the admin URI displayed after installation. It will be something like /admin_xyz123. You can change this later for security.

    Post-Installation Tasks

    Finalize Installation
    # Disable maintenance mode
    bin/magento maintenance:disable
    
    # Deploy static content
    bin/magento setup:static-content:deploy -f
    
    # Run indexers
    bin/magento indexer:reindex
    
    # Clear cache
    bin/magento cache:clean
    bin/magento cache:flush
    8

    Configuring Nginx for Magento

    Create an optimized Nginx virtual host configuration for Magento:

    Create /etc/nginx/sites-available/magento:

    Nginx Server Block
    upstream fastcgi_backend {
        server unix:/run/php/php8.2-fpm.sock;
    }
    
    server {
        listen 80;
        listen [::]:80;
        server_name yourdomain.com www.yourdomain.com;
        return 301 https://$server_name$request_uri;
    }
    
    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name yourdomain.com www.yourdomain.com;
    
        set $MAGE_ROOT /var/www/magento;
        set $MAGE_MODE production;
    
        # SSL Configuration (update paths after certbot)
        ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
        ssl_prefer_server_ciphers off;
        ssl_session_cache shared:SSL:10m;
    
        root $MAGE_ROOT/pub;
        index index.php;
    
        # Security headers
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";
        add_header X-XSS-Protection "1; mode=block";
    
        # Include Magento Nginx config
        include /var/www/magento/nginx.conf.sample;
    }
    Enable the Site
    # Create symlink
    ln -s /etc/nginx/sites-available/magento /etc/nginx/sites-enabled/
    
    # Remove default site
    rm /etc/nginx/sites-enabled/default
    
    # Test configuration
    nginx -t
    
    # Reload Nginx
    systemctl reload nginx
    9

    SSL Certificate Setup

    Secure your Magento store with a free Let's Encrypt SSL certificate:

    Install and Run Certbot
    # Install Certbot
    apt install -y certbot python3-certbot-nginx
    
    # Obtain certificate
    certbot --nginx -d yourdomain.com -d www.yourdomain.com
    
    # Set up auto-renewal
    systemctl enable certbot.timer
    
    # Test renewal
    certbot renew --dry-run
    Update Magento Base URL
    cd /var/www/magento
    
    # Update base URLs
    bin/magento config:set web/unsecure/base_url https://yourdomain.com/
    bin/magento config:set web/secure/base_url https://yourdomain.com/
    bin/magento config:set web/secure/use_in_frontend 1
    bin/magento config:set web/secure/use_in_adminhtml 1
    
    # Clear cache
    bin/magento cache:flush

    🔒 SSL Active: Your Magento store is now secured with HTTPS!

    10

    Performance Optimization

    Optimize your Magento installation for maximum performance:

    Enable Production Mode
    cd /var/www/magento
    
    # Switch to production mode
    bin/magento deploy:mode:set production
    
    # Verify mode
    bin/magento deploy:mode:show
    
    # Enable all cache types
    bin/magento cache:enable
    
    # List cache status
    bin/magento cache:status

    Configure Cron Jobs

    Magento requires cron jobs for indexing, emails, and background tasks:

    Set Up Cron Jobs
    # Switch to magento user
    su - magento
    
    # Edit crontab
    crontab -e
    
    # Add these lines:
    * * * * * /usr/bin/php /var/www/magento/bin/magento cron:run >> /var/log/magento.cron.log 2>&1
    * * * * * /usr/bin/php /var/www/magento/update/cron.php >> /var/log/update.cron.log 2>&1
    * * * * * /usr/bin/php /var/www/magento/bin/magento setup:cron:run >> /var/log/setup.cron.log 2>&1

    11

    Security Hardening

    Protect your Magento store with these essential security measures:

    Two-Factor Authentication

    2FA Configuration
    # 2FA is enabled by default in Magento 2.4+
    # Configure supported providers:
    bin/magento security:tfa:providers
    
    # Reset 2FA for a user if needed:
    bin/magento security:tfa:reset admin admin

    Admin Security

    Secure Admin Panel
    # Change admin URL (custom path):
    bin/magento setup:config:set --backend-frontname='secure_admin_path'
    
    # Enable CAPTCHA for admin login:
    bin/magento config:set admin/captcha/enable 1
    
    # Limit admin session lifetime (3600 = 1 hour):
    bin/magento config:set admin/security/session_lifetime 3600
    
    # Enable admin action logging:
    bin/magento config:set admin/admin_notification/enabled 1

    File Permissions

    Set Proper Permissions
    cd /var/www/magento
    
    # Set proper ownership:
    chown -R magento:www-data .
    
    # Set directory permissions:
    find . -type d -exec chmod 755 {} \;
    
    # Set file permissions:
    find . -type f -exec chmod 644 {} \;
    
    # Make bin/magento executable:
    chmod u+x bin/magento

    12

    Backup and Maintenance

    Regular backups are essential for disaster recovery:

    Database Backup
    # Create backup directory
    mkdir -p /var/backups/magento
    
    # Full database backup
    mysqldump -u magento -p magento | gzip > /var/backups/magento/db_$(date +%Y%m%d_%H%M%S).sql.gz

    Regular Maintenance Commands

    Maintenance Tasks
    cd /var/www/magento
    
    # Clean old logs
    bin/magento log:clean --days=7
    
    # Clean generated files (if needed)
    rm -rf var/cache/* var/page_cache/* generated/code/*
    
    # Recompile and redeploy
    bin/magento setup:di:compile
    bin/magento setup:static-content:deploy -f
    bin/magento cache:flush
    13

    Troubleshooting

    Common issues and their solutions when deploying Magento:

    Useful Commands Reference

    TaskCommand
    Clear all cachesbin/magento cache:flush
    Reindex allbin/magento indexer:reindex
    Enable maintenancebin/magento maintenance:enable
    Check modebin/magento deploy:mode:show
    Run cron manuallybin/magento cron:run
    Show installed modulesbin/magento module:status
    Upgrade databasebin/magento setup:upgrade
    Compile DIbin/magento setup:di:compile

    Congratulations!

    You now have a fully configured, production-ready Magento installation on your RamNode VPS. Your store is equipped with optimized caching through Redis, powerful search capabilities via Elasticsearch, and robust security measures.

    Ongoing Maintenance Reminders:

    • • Keep your system updated with regular security patches
    • • Monitor your server resources
    • • Maintain regular backups
    • • Stay current with Magento security announcements