How to move a website to cPanel hosting

The move is done so the site keeps working the whole time: first everything is copied and checked on the new hosting, and only then DNS is changed.

1. Add the domain

If it is not the primary domain, add it in cPanel: how to add a domain. Do not change DNS yet.

2. Move the files

  1. On the old host, pack the site folder into a ZIP archive and download it.
  2. In cPanel, open "File Manager", go to the site folder and upload the archive: uploading files.
  3. Extract the archive: archives in cPanel. Check that the site files are right in the site folder, not in a subfolder.
Extracting the site archive
Extracting the site archive

A large site is easier to move over FTP: FTP in cPanel.

3. Move the database

  1. On the old host, export the database in phpMyAdmin (.sql or .sql.gz file).
  2. In cPanel, create a database and user: databases in cPanel.
  3. Import the dump: database import.
Importing the dump into the new database
Importing the dump into the new database

4. Update the database connection settings

The database name, user and password on the new hosting are different. Put the new ones in the site settings file - for WordPress it is wp-config.php:

define( 'DB_NAME', 'example_shop' );
define( 'DB_USER', 'example_shop' );
define( 'DB_PASSWORD', 'database user password' );
define( 'DB_HOST', 'localhost' );

Files for other CMS are listed in database connection error. You can edit the file right in cPanel: file editor.

5. Test the site before changing DNS

Open the site on the new hosting from your computer without touching DNS. Add a line with the account IP (shown on the cPanel home page) and the domain to the hosts file:

203.0.113.10 example.com www.example.com
  • Windows: C:\Windows\System32\drivers\etc\hosts (Notepad, run as administrator);
  • macOS and Linux: /etc/hosts.

Check the home page, admin login, forms and payments. Remove the line from hosts afterwards.

6. Email

Create the same mailboxes in cPanel: email accounts. The easiest way to move old mail is a mail app: connect the old and the new mailbox over IMAP and drag the folders across.

7. Change DNS

Set the hosting name servers at your registrar or change the domain A record to the account IP. The site starts opening from the new hosting within a few hours. The free SSL certificate is issued automatically: AutoSSL.

Do not cancel the old hosting right away: while DNS updates, some visitors and emails still go there. Wait 2-3 days.

Questions and answers
No, if you change DNS as the last step: until then the site runs on the old hosting.
Add the domain with the account IP to the hosts file on your computer.
No. A free certificate is issued automatically once the domain points to the hosting.