WordPress site migration

Sections

    Every now and then you are required to migrate a WordPress site from one server to the next, it might be that you are migrating from a Windows environment to Linux.  It could even be from a shared hosting environment to a dedicated server.  There are some basic steps to follow in order to ensure that the migration process runs as smoothly as possible, while your existing services continue to function without any interruption.

    INTRODUCTION

    You are required to;
    1)  Download the site files via FTP using FileZilla
    2)  Export the database through phpMyAdmin
    3)  Create your mail accounts on the new server (Please see step 6 for further instructions)

    Before commencing with the backup process and migration of data, disable or delete the following plugins, where applicable:
    a.  WPS-Hide-Login [changes the /wp-admin URL to one of your choice]
    b.  Wordfence [related article: https://wordpress.org/support/topic/fatal-error-with-wordfence-2/]

    Once the above has been completed you should proceed with the migration process.
    4)  Publish the downloaded website files in the relevant directory on the new server environment
    5)  Create a new database and restore the existing database through the new host panel.  This is followed by some best practices, which will be discussed below, to ensure the site displays correctly before updating the DNS or changing the name servers
    6)  Run the IMAP migration tool (free IMAP migration tool:  https://imapsync.lamiral.info/X/) and copy the existing mail accounts and their associated data to the new server.  After completing this process, you should login to the new webmail in order to confirm that all the messages have been copied successfully

    Now that you have a thorough overview of the process, let’s get started with your migration to the new server environment

    PREPARING FOR MIGRATION ON EXISTING SERVER

    1.  DOWNLOAD THE SITE FILES VIA FTP USING FILEZILLA
    – Create an FTP account in the existing host panel (if you haven’t already).
    – Setup this account in FileZilla (in the Site Manager) using the server IP as the hostname, together with the associated username and password
    – Once connected to the file manager, navigate to the PUBLIC_HTML folder and select all the files in that directory
    – Copy the files across to your local drive [right-click and download files instead of moving files via “drag and drop”]

    2.  EXPORT THE DATABASE THROUGH phpMyAdmin
    – Access phpMyAdmin via existing host panel using the database user and password [You are required to obtain the password from the wp-config.php file or alternatively reset the password]
    – Expand the database and then select EXPORT
    – The database (.sql) will be stored on your local drive under DOWNLOADS

    3.  CREATE YOUR MAIL ACCOUNTS ON THE NEW SERVER

    It is best practice to create the new mail accounts using the existing passwords (as long as the passwords meet the required minimum criteria), if you have those stored safely.  Alternatively now is a good time to reset the passwords on the existing host panel and update these on the new host panel/server.  Take the following into consideration when creating Email passwords:
    – Do NOT use the password anywhere else online, e.g. online banking
    – Refrain from using the user’s name in the password [many panels will not allow this]
    – The more complex, the better.  Combine numeric and alpha-numeric, special characters and upper and lower case to ensure adequate password strength
    – Do NOT share your password with anyone
    – Do NOT save the password in your browser if you are accessing the webmail on a computer outside of your secure office/home network

    COMMENCING WITH MIGRATION TO NEW SERVER

    4.  PUBLISH THE DOWNLOADED WEBSITE FILES IN THE RELEVANT DIRECTORY ON THE NEW SERVER
    – Create a new FTP account
    – Replace the existing account settings for your domain in FileZilla with the newly created FTP accounts settings
    – Open the directory on your local drive where you downloaded the site files previously
    – Select all the files and copy them to the PUBLIC_HTML folder on the new panel’s file manager

    Note:
    About .htaccess
    – Windows contains a web.config file, while Linux requires a .htaccess file that manages the configuration of your website
    – We recommend running a clean WordPress install via the Web App Gallery or softaculous, etc which will create the required file for you

    About SSL
    – The SSL should only be installed/renewed once the domain/DNS is pointing to the new server.

    5.  CREATE A NEW DATABASE AND RESTORE THE EXISTING DATABASE
    – Create a new MySQL database in Direct Admin
    – Copy and paste the username and password in a notepad as you will need this shortly
    – In Direct Admin, select the database and navigate to UPLOAD BACKUP
    – Insert the database you downloaded previously and enter the username and password for the new database (Custom username and password)
    – You are now required to update the WP-CONFIG.PHP file with the details of the new database, database user and password

    Note:
    Update wp-config.php
    The wp-config file contains the database details.  Once you have restored the site files, you are required to update these details in order for the site to access the database
    – Navigate to the FILE MANAGER
    – Select the wp-config file and EDIT the file
    – Update the database name, user and password
    – Save the changes

    Update hosts file
    In order to view your website in a browser on the new server before pointing the domain/DNS, you are required to update the hosts file;
    – Press the WINDOWS key
    – Search for NOTEPAD
    – Right-click on Notepad and the select RUN AS ADMINISTRATOR
    – From Notepad, open the file c:\Windows\System32\Drivers\etc\hosts
    – Add the new server IP and the website address
    – Save your changes

    6. RUN THE IMAP MIGRATION TOOL
    Emails can be copied to the new hosting space by following this tutorial:  https://kb.netmask.host/kb-article/transfer-imap-email/

    Please confirm e-Mail account settings and webmail URL by navigating to our mail settings tool.  This should be done after the domain DNS have been updated to point to the new server.
    –  Enter your e-Mail address or domain name in the blank address bar and hit “GO“.
    –  Once rendered you will be provided with your Email account settings and webmail URL (which you will require when accessing your mailbox online).

    Note:
    Update hostname
    – The hostname contains the incoming and outgoing name server.  These details vary, but the recommended settings can be found by navigating to our useful mail tool
    – Please ensure that you enable SSL to secure the messages that are being sent and received.  In the unfortunate event of a message being intercepted, the contents can NOT be access, seeing that the message is encrypted.

    Do’s and dont’s When pointing to Cloudflare

    • “Grey-cloud” your mail-related DNS records so mail traffic isn’t proxied through Cloudflare.
    • Use separate IP addresses for mail traffic and HTTP/HTTPS traffic. Cloudflare recommends using non-contiguous IPs from different IP ranges.
    • Since mail traffic cannot be proxied through Cloudflare by default, you will expose your origin web server’s IP address. Information on your origin IP address would allow attackers to bypass Cloudflare security features and attack your web server directly.
    • Don’t configure MX records for a root domain that is proxied through Cloudflare.
    • Many hosting companies specify the root domain name in the content of the MX record. When using Cloudflare’s DNS, specify a subdomain such as “mail.example.com” in the content of the MX record  and create a separate A record in Cloudflare for “mail.example.com” to point to the IP address of your mail server.

    Courtesy of Cloudflare online support:
    https://support.cloudflare.com/hc/en-us/articles/200168876-Email-undeliverable-when-using-Cloudflare

    WRAP-UP

    After successful completion of the above steps, please ensure the below is updated accordingly PRIOR to transferring the domain, should you wish to do so.

    Point your domain to the new server by updating the DNS 
    – Request that your IT technician update the DNS of your domain and change the A / WWW records to that of your specific panel
    IP for Shared Linux hosting on Direct Admin
    156.38.169.210
    IP for Shared Windows hosting on Plesk 
    156.38.171.103

    Please note that should you wish for the Emails to also relay through our servers, the NAME SERVERS should be changed to the below instead:
    –  Name servers for Direct Admin
    nsda1.netmask.host
    nsda2.netmask.host
    –  Name servers for Plesk
    nspk1.netmask.host
    nspk2.netmask.host

    Alternatively, the MX RECORDS may be updated, should you wish to keep the name servers as is with your current provider;
    –  MX records for Direct Admin
    da01.netmask.host, priority [10]
    –  MX records for Plesk
    plesk01.netmask.host, priority [10]

    You can now Initiate the domain transfer via the WHMCS Client Area.  The login credentials would have been sent to you after successful sign-up
    –  A ticket request for the domain transfer, will be sent to the correct authority, after – if applicable – the website/database and e-Mails have been setup
    –  The registrant (owner) of the domain will receive the transfer request which they should accept if they would like to continue with the transfer
    –  Domains will then transfer to our hosting environment, co.za’s typically take about 24 hours but .com type domains up to 7 days
    –  We can time this transfer if you prefer, please just let us know what works best for you, if you are not sure, we recommend doing this on a Friday if you have many Email addresses linked to your account

    Congratulations!  You have successfully migrated to your new server

    Related Articles

    Did this article answer your question?