How to Move WordPress to a VPS Using CloudPanel: A Step-by-Step Guide

Migrating a WordPress site from standard hosting to a VPS with CloudPanel in one hour: export, creating the site and database, import, checking the hosts file, SSL, and common mistakes.

This guide is for anyone who is migrating a WordPress site from standard hosting to a VPS with CloudPanel and wants to do it themselves. A typical business card site or small online store can be migrated in about an hour, and the old site remains up and running the entire time. The commands have been tested on CloudPanel 6.

What to Prepare

  • Access to the old hosting: control panel or FTP and phpMyAdmin.
  • DNS access for the domain: through the registrar or Cloudflare.
  • A VPS with CloudPanel installed and administrator access to the control panel.
  • One day before the migration, reduce the TTL of the domain's A record to 300 seconds. That way, after the address changes, the website will be accessible from the new server in just a few minutes, rather than a few hours.

Step 1. Download the files and database from your old hosting provider

Files. In the hosting file manager, compress the website folder (usually public_html or www) and download the archive. If the hosting provider supports SSH, it's faster to do it this way:

tar -czf site.tar.gz -C ~/public_html .

Database. The database name, username, and password are listed in the file wp-config.php. Export the database in phpMyAdmin (the «Export» tab, SQL format) or via SSH:

mysqldump -u USER_NAME -p DATABASE_NAME | gzip > db.sql.gz

Step 2. Create a website in CloudPanel

In CloudPanel, click Add Site and select Create a PHP Website. The «Create a WordPress Site» option isn't suitable: it sets up a new, empty WordPress installation, but we need an empty site for your files. Select:

  • Application: WordPress. This is a web server configuration template specifically for WordPress.
  • Domain Name: your domain, for example www.example.com.ua.
  • PHP Version: the same version or a newer one than on the old hosting service. You can check the version in the old hosting control panel or in the WordPress section «Tools → Site Health → Information.».
  • Site User and a password. You'll then use this username to log in via SFTP.

The same thing with a single command as root:

clpctl site:add:php --domainName=www.example.com.ua --phpVersion=8.3 --vhostTemplate='WordPress' --siteUser=example --siteUserPassword='StrongPassword'

The website files will be stored in the folder /home/example/htdocs/www.example.com.ua.

Step 3. Create a database

In the site settings, open the tab Databases → Add Database and enter the database name, username, and password. Or use the command:

clpctl db:add --domainName=www.example.com.ua --databaseName=example_wp --databaseUserName=example_wp --databaseUserPassword='AnotherSecurePassword'

Step 4. Upload the files

Connect via SFTP (for example, using FileZilla) to the server's IP address using your website username and upload the archive to the website folder. Then extract it via SSH:

cd /home/example/htdocs/www.example.com.ua
tar -xzf site.tar.gz && rm site.tar.gz

If you extracted the files from the root directory, restore the file ownership; otherwise, WordPress won't be able to update or load images:

chown -R example:example /home/example/htdocs/www.example.com.ua

Step 5. Import the database

Download db.sql.gz to the server and run the following in the folder containing the file:

clpctl db:import --databaseName=example_wp --file=db.sql.gz

If working in the console is inconvenient, you can import the database via phpMyAdmin, which can be accessed from the "Databases" tab in CloudPanel.

Step 6. Specify the new database in wp-config.php

Open wp-config.php in the website folder and replace the four lines with the data from step 3:

define( 'DB_NAME', 'example_wp' );
define( 'DB_USER', 'example_wp' );
define( 'DB_PASSWORD', 'AnotherStrongPassword' );
define( 'DB_HOST', 'localhost' );

Step 7. Test the website before switching the domain

Visitors are currently seeing the old server. To view the new one only on your own computer, add a line to the hosts file (on Windows, it's located in C:\Windows\System32\drivers\etc\hosts, open it with Notepad as an administrator; on macOS and Linux, this is /etc/hosts):

NEW_SERVER_IP  example.com.ua www.example.com.ua

Open the website, browse through the pages, log in to the admin panel, and place a test order if it's an online store. The browser may display a certificate warning because SSL hasn't been installed yet; this is normal at this stage. After testing, delete the line from the hosts file.

Step 8. Point the domain and install SSL

In the domain's DNS settings, replace the IP addresses in the A records (for the domain and for www) with the new server's address. Once the domain starts loading from the new server, install a free certificate: in CloudPanel, go to the SSL/TLS → Actions → New Let’s Encrypt Certificate. Or with the command:

clpctl lets-encrypt:install:certificate --domainName=www.example.com.ua --subjectAlternativeName=example.com.ua

Read more about certificates in the article Free SSL certificates for VPS via CloudPanel.

Step 9. What to Check After Moving

  • Mail. If the email service for your domain was hosted on your old hosting provider, do not change the MX records until you decide where it will be hosted next. Only change the website's A records.
  • Scheduled tasks. If there were cron jobs on your old hosting account, move them to the tab Cron Jobs website in CloudPanel.
  • Cache. Clear the cache for caching plugins and Cloudflare, if applicable.
  • Old hosting Don't shut it down for another week. If you've forgotten anything, the files and database will be right at your fingertips.

If something goes wrong

«Error establishing a database connection.». Incorrect data in wp-config.php. Verify the database name, username, and password against the "Databases" tab.

A blank screen or a 500 error. Most often, it's the wrong version of PHP or a plugin that's incompatible with a newer version of PHP. Check the error log in the tab Logs of the website and, if necessary, change the PHP version in the tab Settings.

Endless redirects or «mixed content» after SSL. The database contains an address starting with http://. WP-CLI is already installed on CloudPanel, so this can be fixed with a single command from the site's folder by the site user:

wp search-replace 'http://www.example.com.ua' 'https://www.example.com.ua' --skip-columns=guid

Error 403 or WordPress cannot load the files. The files have the wrong owner. Change it using the command chown from step 4.

Don't want to do it yourself?

CloudPanel is already installed on VPSio.cloud servers, and we handle the website migration for free: files, database, and a check before the switch. We don’t touch the old hosting until the check is complete. The servers are located in Germany and Finland, so your website won’t be affected by power outages in Ukraine—more on this in a separate article. Where is your website physically hosted, and what should you do if the data center goes offline?.