Knowledge base article

Migrate remote staging website to local hosting server

View other cpanel articles

Ready to go live with your new website? This guide advises steps on migrating your remote staging website to your Serversaurus cPanel hosting

This guide is WordPress specific however the steps can be easily adjusted for most content management systems.

To complete this guide, please ensure you have:

  • SSH Access - Serversaurus relies on key based authentication to login via SSH/SFTP, if you haven't already, generate your SSH key pair and configure it in cPanel before proceeding with the next steps
  • SSH access to the remote hosts - If the remote host doesn't allow SSH access, we've included a wget command which is FTP compatible. - These can be found within the wp-config.php file.

New to rsync or wget? these helpful command line tools enable you to import the directory contents from a remote host to your local directory (or vise versa).

Let's get started!

  1. SSH to the remove hosts server and generate a database dump:
    Update the following command with your remote SSH username and server hostname.

    ssh username@remote.hostname.com.au
    

    Change into your websites document root, for cPanel hosting this is often ~public_html, however it varies between hosts:
    Update the following command with the correct path if required.

    cd public_html/

    Export the database:
    Adjust the below command to include your MySQL username and password. You can find your database login credentials within wp-config.php if required

    mysqldump -u username -p database_name > backup.sql
  2. Open a new terminal window and SSH to your Serversaurus hosting server:
    Update the following command with your Serversaurus SSH username and server hostname.

    ssh username@servername.serversaurus.com.au
  3. Change into the website document root:
    cd public_html
  4. Check your present working directory using the following command and store the path details for the following steps:
    pwd
  5. For users with SSH access - Use the following rsync command to synchronize the remote website directory with your present working directory:
    Update the command with your remote host login details and directory path.

    rsync -avzh username@remote.hostname.com.au:/path/to/document/root /path/to/present/directory/
    

    For users with FTP access - Use the following wget command to recursively import the remote website directory with the path to your present working directory:Update the command with your remote host login details and directory path.

    wget -m -x -nH -nv --ftp-user=username --ftp-password=xxxxxxxxxxxxx ftp://remote.hostname.com.au/path/to/document/root
  6. Correct the ownership and permissions using the following commands:
    Update the following command with your Serversaurus cPanel username.

    chown -R username:username *
  7. Change document root ownership to nobody:
    Update the following command with the correct path if required.

    chgrp nobody ../public_html
  8. Recursively update the directory permissions:
    find . -type d -exec chmod 755 {} ;

    Recursively update the file permissions:

    find . -type f -exec chmod 644 {} ;
  9. Update wp-config.php with your database login details, if required use the MySQL Database Wizard function in cPanel to create a database and database user.
    Edit the wp-config.php file using vi:

    vi wp-config.php

    Update the following section with your database login details:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'your_database');
    
    /** MySQL database username */
    define('DB_USER', 'database_user');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
  10. Login to MySQL using the below command, enter your password when prompted:
    Update the command with your database user.

    mysql -u username -p;

    Import the database:
    Update the following command with the document root path.

    source /path/to/document/root/backup.sql;

    Once complete, exit MySQL:

    exit

The migration is finished! Nice work!

Troubleshooting recommendations:
If you have any warnings/errors, please check for the following common post migration issues.

  1. Login to WordPress and clear all website cache.
  2. Check DNS is resolving to correct server IP address.
  3. Login to phpMyAdmin, check wp_options table and confirm the siteurl and home are pointing to the correct domain name- update if required.
  4. Check all PHP dependencies are enabled.

Last updated November 30, 2023

Can't find what you're looking for?

Submit a question

  • Drop files here or
    Max. file size: 2 MB, Max. files: 3.
    • This field is for validation purposes and should be left unchanged.