主服务器域名切换域名服务器(Nameservers)技术咨询
Hey there, let’s break down how to pull off your site migration smoothly given your specific setup with WHM/cPanel and a domain registered at Fasthosts. I’ve dealt with tons of similar scenarios, so here’s a step-by-step guide with key checks to avoid headaches:
Before diving into migration, make sure your custom NS records are actually working—this is a common pain point when using external domain registrars:
- Verify that
ns1.example.comandns2.example.compoint directly to your WHM server (whm.example.com) IP. Run these commands in your terminal to confirm:
Both should return the exact public IP ofdig ns1.example.com A +short dig ns2.example.com A +shortwhm.example.com. If not, head back to WHM’s DNS Zone Editor forexample.comand fix the A records for your NS entries. - Double-check Fasthosts’ domain settings: Ensure you’ve fully replaced their default nameservers with
ns1.example.comandns2.example.com—no leftover old NS records allowed here.
Migration can go sideways, so cover your bases:
- Full cPanel Account Backup: Log into WHM, navigate to Backup > Backup User Accounts, select the accounts you’re migrating, and choose a full backup (includes files, databases, emails, and settings). Save it locally or to a secure external storage—don’t rely solely on server-side backups.
- Separate Database Export: For extra safety, export each site’s database via cPanel’s phpMyAdmin: Select the database, click Export, pick the Quick mode, and save the SQL file to your computer. This gives you a fallback if the full backup has issues.
Option 1: Use WHM’s Transfer Tool (Best for cPanel-to-cPanel)
This is the easiest route if your source server is also running WHM/cPanel:
- In WHM, go to Transfers > Transfer Tool
- Enter your source server’s IP/domain, WHM username, and password
- Select the accounts you want to move, check Copy Accounts and Copy DNS Zones to sync DNS records automatically
- Start the transfer and monitor the log for errors—WHM handles most heavy lifting like file sync, database imports, and mail migration.
Option 2: Manual Migration (For Non-cPanel Sources)
If your old server isn’t cPanel, you’ll need to do a bit more legwork:
- File Sync: Use
rsync(faster than FTP) to copy site files to the target cPanel account’spublic_htmldirectory:
After syncing, fix file permissions: Set directories torsync -avz old-server-username@old-server-ip:/home/old-server-username/public_html/ /home/new-cpanel-username/public_html/755and files to644(you can do this via cPanel’s File Manager or terminal). - Database Setup: Create a new database and user in cPanel’s MySQL Databases, grant full permissions, then import your saved SQL file via phpMyAdmin.
- Mail Migration: Use a tool like ImapSync to sync emails from your old server to the new cPanel mail accounts, or download emails locally via your mail client and re-import them.
Don’t flip the switch until you’ve verified everything works:
- Local Hosts File Test: Edit your computer’s hosts file to map your site domains to the target server’s IP. This lets you test the live site without affecting real users:
- Windows:
C:\Windows\System32\drivers\etc\hosts - Linux/macOS:
/etc/hosts
Add a line like:
Visit the site, test forms, database-driven content, and email sending/receiving to confirm all functions work.123.45.67.89 your-site-domain.com - Windows:
- Wait for DNS Propagation: Once testing passes, let DNS do its thing (usually 24-48 hours). You can speed this up by lowering your domain’s TTL to 300 seconds a day before migration—this reduces cache time across DNS servers.
- Post-Migration Checks: Use
digto confirm your site’s NS records point tons1/ns2.example.comand the A record matches your target server IP:dig your-site-domain.com NS +short dig your-site-domain.com A +short
- 500 Internal Server Error: Almost always a permission issue—double-check file/directory ownership matches your cPanel username, and set permissions to
755(dirs) /644(files). - Database Connection Failures: Verify your site’s config file (like
wp-config.phpfor WordPress) has the correct database name, username, and password from the target cPanel setup. - DNS Delays: If some users still see the old site, remind them to clear their browser cache or wait for their local DNS to refresh.
内容的提问来源于stack exchange,提问作者user3058948

