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 Size | RAM | vCPUs | Storage | RamNode Plan |
|---|---|---|---|---|
| Small (< 1,000 SKUs) | 4 GB | 2 cores | 50 GB SSD | Premium KVM 4GB |
| Medium (1,000-10,000 SKUs) | 8 GB | 4 cores | 100 GB SSD | Premium KVM 8GB |
| Large (10,000+ SKUs) | 16 GB | 6 cores | 200 GB SSD | Premium KVM 16GB |
| Enterprise | 32 GB+ | 8+ cores | 400 GB+ SSD | Premium 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
Initial Server Setup
Connect to your RamNode VPS and perform essential system configuration:
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# 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-8Installing the LEMP Stack
The LEMP stack (Linux, Nginx, MySQL, PHP) forms the foundation for running Magento:
Install Nginx
# Install Nginx
apt install -y nginx
# Start and enable Nginx
systemctl start nginx
systemctl enable nginx
# Verify installation
nginx -vInstall MySQL 8.0
# Install MySQL Server
apt install -y mysql-server
# Start and enable MySQL
systemctl start mysql
systemctl enable mysql
# Secure the installation
mysql_secure_installation# 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
# 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 -vInstalling Elasticsearch
Elasticsearch is required for Magento 2.4+ catalog search functionality:
# 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 Elasticsearch
apt install -y elasticsearchConfigure for Magento by editing /etc/elasticsearch/elasticsearch.yml:
cluster.name: magento-cluster
node.name: magento-node-1
network.host: 127.0.0.1
http.port: 9200
xpack.security.enabled: false# Start and enable Elasticsearch
systemctl daemon-reload
systemctl start elasticsearch
systemctl enable elasticsearch
# Verify installation
curl -X GET 'http://localhost:9200'Installing and Configuring Redis
Redis dramatically improves Magento performance by caching sessions, full-page cache, and application cache in memory:
# Install Redis
apt install -y redis-server
# Verify installation
redis-server --versionEdit /etc/redis/redis.conf with optimizations:
# 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# Restart and enable Redis
systemctl restart redis-server
systemctl enable redis-server
# Test connection
redis-cli -a your_redis_password pingRedis Database Layout for Magento
| Database | Purpose | Description |
|---|---|---|
| 0 | Default/Backend Cache | Configuration, layouts, blocks |
| 1 | Page Cache | Full page cache storage |
| 2 | Session Storage | Customer sessions |
Installing Composer
Composer is required to install Magento and manage its dependencies:
# 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.
Magento Installation
Install Magento using Composer and run the setup wizard:
# 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# 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 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/magentobin/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
# 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:flushConfiguring Nginx for Magento
Create an optimized Nginx virtual host configuration for Magento:
Create /etc/nginx/sites-available/magento:
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;
}# 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 nginxSSL Certificate Setup
Secure your Magento store with a free Let's Encrypt SSL certificate:
# 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-runcd /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!
Performance Optimization
Optimize your Magento installation for maximum performance:
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:statusConfigure Cron Jobs
Magento requires cron jobs for indexing, emails, and background tasks:
# 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>&1Security Hardening
Protect your Magento store with these essential security measures:
Two-Factor Authentication
# 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 adminAdmin Security
# 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 1File 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/magentoBackup and Maintenance
Regular backups are essential for disaster recovery:
# 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.gzRegular Maintenance Commands
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:flushTroubleshooting
Common issues and their solutions when deploying Magento:
Useful Commands Reference
| Task | Command |
|---|---|
| Clear all caches | bin/magento cache:flush |
| Reindex all | bin/magento indexer:reindex |
| Enable maintenance | bin/magento maintenance:enable |
| Check mode | bin/magento deploy:mode:show |
| Run cron manually | bin/magento cron:run |
| Show installed modules | bin/magento module:status |
| Upgrade database | bin/magento setup:upgrade |
| Compile DI | bin/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
