Linux VPS

Migrate sites from a LAMP or LEMP VPS to cPanel hosting

Move websites from a plain Linux VPS (Apache or nginx, PHP, MySQL) to MdmHost cPanel: find vhosts, dump databases, copy files with rsync, convert rules and switch DNS.

AdvancedLinux VPS to cPanel4 min read

A LAMP or LEMP VPS to cPanel migration moves hand-built sites with no control panel onto managed cPanel hosting. With no panel there is no backup button, so you collect each site's configuration by hand. This guide shows how to find everything on the VPS and rebuild it on MdmHost.

Before you start

  • Root or sudo SSH access to the VPS.
  • An MdmHost cPanel account with SSH access enabled, if you want to rsync directly.

Find every site on the VPS

List virtual hosts and their document roots:

grep -RiE "server_name|root " /etc/nginx/sites-enabled/ /etc/nginx/conf.d/ 2>/dev/null
grep -RiE "ServerName|ServerAlias|DocumentRoot" /etc/apache2/sites-enabled/ /etc/httpd/conf.d/ 2>/dev/null

Then list databases and cron jobs:

mysql -e "SHOW DATABASES;"
for u in $(cut -d: -f1 /etc/passwd); do crontab -l -u "$u" 2>/dev/null | sed "s/^/$u: /"; done

Back up databases and files

mysqldump --single-transaction --routines --triggers dbname | gzip > /root/dbname.sql.gz
tar -czf /root/example.com.tar.gz -C /var/www/example.com .

Full details in mysqldump backup and restore.

LAMP/LEMP to cPanel migration: copy and restore

  1. Add each domain in cPanel → Domains → Domains and note its document root.
  2. Push files from the VPS straight to cPanel (replace the user, host and port):
rsync -avz -e "ssh -p 22" /var/www/example.com/ cpuser@server.example.net:public_html/
  1. Create databases in Manage My Databases and import the dumps.
  2. Update app config files with the new database names and users.
  3. Recreate cron jobs in cPanel → Cron Jobs.

Convert nginx rules

cPanel at MdmHost uses LiteSpeed, which reads Apache-style .htaccess rules. A common nginx front-controller rule:

location / { try_files $uri $uri/ /index.php?$args; }

becomes:

RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]

Migrate email with IMAP sync

Mailboxes rarely restore cleanly between different control panels, so the dependable method is to create the same addresses in cPanel → Email → Email Accounts and copy the messages over IMAP:

  1. List every mailbox on the VPS with its approximate size.
  2. Create the same addresses on cPanel and give each enough quota.
  3. Run an IMAP sync per mailbox from the old server (by IP or hostname, since DNS still points there) to the new one. imapsync between servers explains the command; migrate email to cPanel over IMAP covers the cPanel side.
  4. After the DNS switch, run the same sync again. imapsync skips messages it has already copied, so the second pass only picks up mail that arrived in between.

Tip: Forwarders, autoresponders and filters are not copied by IMAP. Note them down on the old panel and recreate them under cPanel → Email.

Switch DNS with minimal downtime

  1. One or two days before the move, lower the TTL of the A, AAAA and MX records at the current DNS host to 300 seconds. See DNS TTL strategy for a server migration.
  2. Test the new copy before switching: add the new server IP for the domain to your computer's hosts file and browse the site.
  3. Freeze changes on the old site (no new orders, posts or comments), take a final database export and import it on cPanel if content has changed since the first copy.
  4. Either point the A records to the new IP, or change the domain's nameservers to the ones in your MdmHost welcome email. Changing records is faster when the TTL is already low; nameserver changes can take up to 24–48 hours.
  5. Keep the old account running for at least a week so slow resolvers and delayed mail still land somewhere.

Post-migration checks

  • The site loads over HTTPS with a valid certificate. AutoSSL issues it once DNS points to MdmHost; run it from cPanel → Security → SSL/TLS Status if needed.
  • Forms, logins, checkouts and uploads work, and there are no database connection errors.
  • Sending and receiving email works from webmail and from your mail client, and SPF/DKIM pass in cPanel → Email → Email Deliverability.
  • Cron jobs are recreated under cPanel → Advanced → Cron Jobs with the new paths (/home/username/…).
  • The PHP version in cPanel → Software → MultiPHP Manager matches what the old server used.

Troubleshooting

  • Missing PHP extensions: compare php -m on the VPS with Select PHP Version in cPanel.
  • Hard-coded paths: search config for /var/www and replace with /home/cpuser/public_html.

FAQ

Can daemons or Docker containers move to cPanel?

Shared cPanel hosting runs websites, not long-running daemons or containers; keep those on a VPS.

Does file ownership matter?

rsync into the cPanel account makes files owned by your cPanel user automatically.

What about Let's Encrypt certificates?

Don't copy them; AutoSSL issues new ones after the DNS switch.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.