AWS Server Migration & Optimization Guide

From Plesk to CyberPanel with AI/Development Integration

Executive Summary

Current Setup:

  • Server: AWS EC2 m5a.large (2 vCPUs, 8GB RAM)
  • OS: AlmaLinux with Plesk Obsidian
  • Hosting: 15 WordPress websites

Migration Objective:

  • Keep m5a.large instance
  • Remove Plesk, install CyberPanel (free, open-source)
  • Optimize WordPress performance
  • Repurpose unused resources for AI/development work

Phase 1: Preparation & Backup

Critical: Complete Backups Before Starting

1.1 Create Plesk Backup

# Full backup of all sites
sudo plesk bin pleskbackup --all /backup/plesk-full-backup.tar

# Individual domain backup (repeat for each site)
sudo plesk bin pleskbackup domains --domains-name=yourdomain.com /backup/

1.2 Document Current Configuration

Create a spreadsheet with:

  • All domain names
  • PHP versions per site
  • Database names and users
  • Email configurations
  • DNS records (export from Plesk)
  • SSL certificate details
  • Any custom configurations

1.3 AWS Snapshot

  1. Go to AWS EC2 Console
  2. Select your instance
  3. Actions → Image and templates → Create image
  4. Name it: "plesk-backup-YYYY-MM-DD"
  5. Wait for AMI creation to complete
This snapshot is your insurance policy!

Phase 2: Choose Your Control Panel

Recommended: CyberPanel

Why CyberPanel?

Advantages:

  • Free and open-source
  • OpenLiteSpeed web server (faster than Apache/NGINX for WordPress)
  • Built-in LSCache (exceptional WordPress performance)
  • Docker integration for AI/development work
  • Automatic SSL with Let's Encrypt
  • Modern, user-friendly interface
  • Git integration
  • One-click WordPress installation

Resource Usage:

  • Base footprint: ~1-1.5GB RAM
  • Leaves plenty of resources for AI/development

Alternative: HestiaCP

  • Lighter weight (~500MB RAM)
  • More traditional Apache/NGINX setup
  • Easier learning curve if coming from Plesk
  • Good option if you need maximum resources for AI work

Phase 3: Installation Strategy

Recommended Approach: Fresh Installation

Why Fresh Installation?

  • Both servers run simultaneously during migration
  • Easy rollback if issues arise
  • Clean environment without Plesk remnants
  • Test thoroughly before committing
  • Zero downtime migration possible

Steps Overview:

  1. Launch new m5a.large instance
  2. Install CyberPanel
  3. Migrate sites one by one
  4. Test each site thoroughly
  5. Update DNS when ready
  6. Monitor for 48-72 hours
  7. Terminate old instance

Phase 4: Detailed Installation

4.1 Launch New EC2 Instance

Instance Configuration:

  • AMI: AlmaLinux 9 (or Rocky Linux 9)
  • Instance Type: m5a.large
  • Storage: 100GB+ GP3 SSD (same as current)
  • Security Group: Open ports 80, 443, 8090, 22

Security Group Rules:

Type Protocol Port Range Source
SSH TCP 22 Your IP
HTTP TCP 80 0.0.0.0/0
HTTPS TCP 443 0.0.0.0/0
Custom TCP TCP 8090 Your IP
Custom TCP TCP 3000-3010 Your IP (for AI/dev)

4.2 Initial Server Setup

# SSH into new server
ssh -i your-key.pem ec2-user@your-new-server-ip

# Update system
sudo dnf update -y

# Install essential tools
sudo dnf install wget curl nano htop -y

# Set hostname (optional)
sudo hostnamectl set-hostname your-hostname

4.3 Install CyberPanel

# Download and run installer
sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)

Installation Prompts:

  1. Install CyberPanel Version: Choose option 1 (Latest)
  2. Install Type: Choose option 1 (Full installation with email, DNS, FTP)
  3. Choose Your RAM: Press Enter (auto-detect)
  4. Setup Remote MySQL: No (press 'n')
  5. Setup Memcached: Yes (press 'y')
  6. Setup Redis: Yes (press 'y')
  7. Set Admin Password: Choose a strong password
  8. Watchdog: Yes (recommended)

Installation takes 15-30 minutes.

4.4 Access CyberPanel

URL: https://your-server-ip:8090
Username: admin
Password: (password you set during installation)

First Login Steps:

  1. Complete initial setup wizard
  2. Set timezone
  3. Configure nameservers (if using CyberPanel DNS)
  4. Enable automatic updates

Phase 5: WordPress Migration

5.1 Pre-Migration Checklist

For each WordPress site, document:

  • Domain name
  • Current PHP version
  • Database size
  • File size
  • Active plugins
  • Theme in use
  • Any custom configurations

5.2 Migration Process (Per Site)

Step 1: Export from Plesk Server

# SSH into OLD Plesk server
ssh -i your-key.pem ec2-user@old-server-ip

# Export database
mysqldump -u db_username -p db_name > ~/yourdomain-db.sql

# Create tarball of WordPress files
cd /var/www/vhosts/yourdomain.com/httpdocs
tar -czf ~/yourdomain-files.tar.gz .

# Download to your local machine
# On your local computer:
scp -i your-key.pem ec2-user@old-server-ip:~/yourdomain-db.sql .
scp -i your-key.pem ec2-user@old-server-ip:~/yourdomain-files.tar.gz .

Step 2: Create Website in CyberPanel

  1. Login to CyberPanel (https://new-server-ip:8090)
  2. Go to: Websites → Create Website
  3. Fill in details:
    • Select Package: Default
    • Domain Name: yourdomain.com
    • Email: [email protected]
    • Select PHP: (match your current version)
    • SSL: Check "Issue SSL"
  4. Click "Create Website"
  5. Go to: Databases → Create Database
    • Database Name: yourdomain_db
    • Username: yourdomain_user
    • Password: (secure password)

Step 3: Upload Files to New Server

# Upload files to new server
scp -i your-key.pem yourdomain-files.tar.gz ec2-user@new-server-ip:/home/yourdomain.com/

# SSH into new server
ssh -i your-key.pem ec2-user@new-server-ip

# Extract files
cd /home/yourdomain.com/public_html
sudo tar -xzf ../yourdomain-files.tar.gz
sudo rm ../yourdomain-files.tar.gz

# Upload and import database
scp -i your-key.pem yourdomain-db.sql ec2-user@new-server-ip:/tmp/

# Import database
mysql -u yourdomain_user -p yourdomain_db < /tmp/yourdomain-db.sql
rm /tmp/yourdomain-db.sql

Step 4: Update wp-config.php

sudo nano /home/yourdomain.com/public_html/wp-config.php

# Update these lines:
define('DB_NAME', 'yourdomain_db');
define('DB_USER', 'yourdomain_user');
define('DB_PASSWORD', 'your-new-password');
define('DB_HOST', 'localhost');

# Save and exit (Ctrl+X, Y, Enter)

Step 5: Fix Permissions

sudo chown -R yourdomain:yourdomain /home/yourdomain.com/public_html/
sudo find /home/yourdomain.com/public_html/ -type d -exec chmod 755 {} \;
sudo find /home/yourdomain.com/public_html/ -type f -exec chmod 644 {} \;

Step 6: Install LSCache Plugin

  1. Login to WordPress admin (http://new-server-ip/wp-admin)
  2. Update /etc/hosts on your local machine to test:
    new-server-ip yourdomain.com
  3. Go to Plugins → Add New
  4. Search for "LiteSpeed Cache"
  5. Install and activate
  6. Go to LiteSpeed Cache → Settings
  7. Click "Enable" at the top
  8. Use preset: "WordPress" or "WooCommerce"

Step 7: Test Website

  • Homepage loads correctly
  • All pages accessible
  • Images display properly
  • Forms work
  • Admin panel accessible
  • Plugins functioning
  • Theme displays correctly
  • SSL certificate active

Phase 6: Repurpose for AI/Development

6.1 Resource Allocation

m5a.large Total Resources:

  • 2 vCPUs
  • 8GB RAM

Recommended Allocation:

  • WordPress + CyberPanel: 4-5GB RAM, ~1.5 vCPUs
  • AI/Ollama: 2-3GB RAM, ~0.5 vCPUs
  • Development Containers: 1GB RAM (on-demand)
  • System overhead: ~500MB RAM

6.2 Install Docker

# Add Docker repository
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

# Install Docker
sudo dnf install docker-ce docker-ce-cli containerd.io -y

# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker

# Add user to docker group
sudo usermod -aG docker $USER

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Verify installation
docker --version
docker-compose --version

6.3 Set Up Ollama for Local AI

Install Ollama:

# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

# Start Ollama service
sudo systemctl start ollama
sudo systemctl enable ollama

# Verify installation
ollama --version

Pull AI Models:

# Small, efficient models for m5a.large:

# Llama 3.2 1B (1.3GB) - Fast, good for simple tasks
ollama pull llama3.2:1b

# Phi-3 Mini (2.3GB) - Microsoft's efficient model
ollama pull phi3:mini

# Mistral 7B (4.1GB) - More powerful, use only if you have RAM available
ollama pull mistral:7b-instruct

# Test a model
ollama run llama3.2:1b

Phase 7: Testing & Cutover

7.1 Pre-Cutover Checklist

For Each WordPress Site:

  • Site accessible via IP address
  • All pages load correctly
  • Images and media display
  • Forms submit properly
  • Admin panel works
  • Plugins active and functional
  • SSL certificate installed
  • LSCache configured
  • Performance tested
  • Backup created

7.2 DNS Cutover Strategy

Gradual Cutover (Recommended):

  1. Week 1: Migrate and test 3-5 sites
  2. Week 2: Migrate another 5 sites
  3. Week 3: Migrate remaining sites
  4. Week 4: Monitor, optimize, decommission old server

7.3 Rollback Plan

If Issues Arise:

  1. Immediately: Point DNS back to old server
  2. Investigate issue on new server
  3. Fix problem
  4. Re-test thoroughly
  5. Update DNS again when ready
Old Server Retention:
Keep old server for 30 days minimum. Maintain backups. Only terminate when 100% confident.

Resource Allocation Guide

Optimal Resource Distribution

CyberPanel + 15 WordPress Sites:

  • Base CyberPanel: 1GB RAM
  • OpenLiteSpeed: 500MB RAM
  • MySQL/MariaDB: 1.5GB RAM
  • PHP-FPM pools: 1.5GB RAM
  • LSCache: 500MB RAM
  • Total: ~5GB RAM, 1.5 vCPUs

AI & Development:

  • Ollama: 2GB RAM, 0.3 vCPUs
  • Docker containers: 1GB RAM, 0.2 vCPUs
  • Total: ~3GB RAM, 0.5 vCPUs

Ongoing Maintenance

Daily Tasks

  • Check CyberPanel dashboard
  • Review server uptime
  • Quick site checks (homepage loads)

Weekly Tasks

  • Review error logs
  • Check disk space
  • Monitor resource usage
  • Test backups
  • Database optimization
  • Security updates

Monthly Tasks

  • Full backup verification
  • Performance analysis
  • Security audit
  • Update all software
  • Review and optimize Docker images
  • Clean up old logs

Troubleshooting Guide

Common WordPress Issues

Issue: 500 Internal Server Error

# Check error logs
sudo tail -f /usr/local/lsws/logs/error.log

# Check PHP error log
sudo tail -f /home/yourdomain.com/logs/error.log

# Fix permissions
sudo chown -R yourdomain:yourdomain /home/yourdomain.com/public_html/

Issue: Database Connection Error

# Verify database exists
mysql -u root -p
SHOW DATABASES;

# Check wp-config.php credentials
sudo nano /home/yourdomain.com/public_html/wp-config.php

# Reset database password if needed
mysql -u root -p
ALTER USER 'username'@'localhost' IDENTIFIED BY 'newpassword';
FLUSH PRIVILEGES;

Performance Issues

High Memory Usage:

# Check what's using memory
htop

# Check Docker usage
docker stats

# Restart services if needed
sudo systemctl restart lsws
docker-compose restart

Security Best Practices

Server Security

1. SSH Hardening:

# Disable root login
sudo nano /etc/ssh/sshd_config
# Set: PermitRootLogin no

# Change SSH port
# Set: Port 2222

# Restart SSH
sudo systemctl restart sshd

WordPress Security

1. Use Strong Passwords:

  • Database passwords
  • WordPress admin passwords
  • CyberPanel admin password

2. Install Security Plugins:

  • Wordfence Security
  • Sucuri Security
  • iThemes Security

Backup Strategy

Automated WordPress Backups

Manual Backup Script:

#!/bin/bash
# Save as: /root/scripts/wordpress-backup.sh

BACKUP_DIR="/backup/wordpress"
DATE=$(date +%Y%m%d)

for site in /home/*/public_html; do
    domain=$(echo $site | cut -d'/' -f3)
    
    # Backup files
    tar -czf $BACKUP_DIR/${domain}_${DATE}.tar.gz $site
    
    # Backup database
    db_name="${domain}_db"
    mysqldump $db_name > $BACKUP_DIR/${domain}_${DATE}.sql
done

# Delete backups older than 30 days
find $BACKUP_DIR -type f -mtime +30 -delete

Support Resources

CyberPanel

Ollama

Docker

Migration Timeline

Immediate (This Week)

  • Create full Plesk backup
  • Create AWS snapshot
  • Document current configuration
  • Launch new EC2 instance
  • Install CyberPanel

Week 1

  • Migrate first 3 test sites
  • Test thoroughly
  • Configure LSCache
  • Install Docker
  • Set up Ollama

Week 2-4

  • Migrate remaining sites
  • Deploy AI Docker stack
  • Configure Redis for WordPress
  • Update DNS for tested sites
  • Monitor performance
  • Final testing and optimization
  • Terminate old instance

FAQ

General Questions

Q: How long will the migration take?

A: Plan for 3-4 weeks total. Active migration work is about 1-2 hours per site, but allow time for testing and DNS propagation.

Q: Will there be any downtime?

A: No. By running both servers simultaneously and updating DNS gradually, you can achieve zero downtime migration.

Q: What if something goes wrong?

A: You have multiple safety nets: AWS snapshots, Plesk backups, and the old server running. You can always roll back by pointing DNS back to the old server.

Technical Questions

Q: Why CyberPanel over other control panels?

A: OpenLiteSpeed (CyberPanel's web server) is significantly faster than Apache for WordPress, LSCache is the best WordPress caching solution, and it's completely free with active development.

Q: Can I use different AI models?

A: Yes! Ollama supports many models. Just be mindful of RAM usage. Models under 4GB work best on this setup.

Appendix A: Useful Commands Reference

CyberPanel CLI

# Restart CyberPanel
sudo systemctl restart lscpd

# Restart OpenLiteSpeed
sudo systemctl restart lsws

# Create website via CLI
cyberpanel createWebsite --domainName example.com --email [email protected] --package Default

# Issue SSL certificate
cyberpanel issueSSL --domainName example.com

Docker Commands

# View running containers
docker ps

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f [service-name]

# Update images
docker-compose pull
docker-compose up -d

# View resource usage
docker stats

System Monitoring

# Real-time process monitoring
htop

# Disk usage
df -h

# Check service status
sudo systemctl status [service-name]

Appendix B: Performance Benchmarks

Expected Performance Improvements

Before (Plesk + Apache):

  • Average page load: 2-4 seconds
  • Time to first byte: 800ms-1.5s
  • Concurrent users: ~50-100
  • Memory per site: ~150-200MB

After (CyberPanel + OpenLiteSpeed + LSCache):

  • Average page load: 0.5-1.5 seconds
  • Time to first byte: 200-400ms
  • Concurrent users: ~200-300
  • Memory per site: ~50-100MB

Appendix C: Scaling Guide

When to Scale Up

Signs you need more resources:

  • Consistent RAM usage above 85%
  • CPU usage consistently above 70%
  • Slow page load times (>2 seconds)
  • Database queries timing out
  • AI models running out of memory

Vertical Scaling (Bigger Instance)

Next instance tier: m5a.xlarge

  • 4 vCPUs (double)
  • 16GB RAM (double)
  • Supports 30-40 WordPress sites
  • Can run larger AI models (13B parameters)

Appendix D: Migration Automation Scripts

Automated Backup Script

#!/bin/bash
# save as: /root/scripts/daily-backup.sh

BACKUP_DIR="/backup"
DATE=$(date +%Y%m%d)

# Backup all WordPress sites
for site in /home/*/public_html; do
    domain=$(echo $site | cut -d'/' -f3)
    
    # Backup files
    tar -czf $BACKUP_DIR/${domain}_${DATE}_files.tar.gz $site
    
    # Backup database
    db_name="${domain//./_}_db"
    mysqldump $db_name | gzip > $BACKUP_DIR/${domain}_${DATE}_db.sql.gz
done

# Delete local backups older than 7 days
find $BACKUP_DIR -type f -mtime +7 -delete

echo "Backup completed: $DATE"

Appendix E: Security Hardening Checklist

Server Level

  • Change SSH port from default 22
  • Disable root SSH login
  • Set up SSH key authentication only
  • Configure firewall (CSF)
  • Enable Fail2Ban
  • Set up automatic security updates
  • Regular security audits
  • Monitor system logs

WordPress Level

  • Strong admin passwords
  • Two-factor authentication
  • Security plugin installed
  • Hide WordPress version
  • Disable file editing
  • Limit login attempts
  • Regular updates

Success Metrics

After migration, you should achieve:

  • 50-70% faster page load times
  • Zero licensing fees for control panel
  • AI/ML capabilities on your infrastructure
  • Professional development environment

Document Information:

  • Version: 1.0
  • Created: October 2025
  • Purpose: Technical Migration Guide
  • Server: AWS EC2 m5a.large