---
title: "Cloning a WordPress Site & Moving It to a New Domain"
source: "https://docs.nexcess.com/sites-stores/cms/wordpress/self-service-migrations/"
description: "Thinking about moving your WordPress site to a new domain? Follow these steps to migrate WordPress to a new domain successfully."
vertical: "Sites & Stores"
date: "2021-11-23"
last_modified: "2026-08-06"
---

# Cloning a WordPress Site & Moving It to a New Domain

If you’re thinking about cloning your WordPress site and moving it to a new domain, you’re in the right place. Keep reading to learn how to clone and migrate your site.

## Consider Using the Recommended BlogVault Features

You have the recommended option of using BlogVault to move a domain (site) on Managed WordPress and Managed WooCommmerce Plans. An informative article to help you in this process is [Migrating to Nexcess with managed WordPress and managed WooCommerce hosting](https://docs.nexcess.com/sites-stores/migrations/nexcess/migration-methods/).

## Prerequisites

For this process of moving your site to a new domain, you will need to connect to the server using **SSH**. If you do not know how to use **SSH**, then the [New User Tutorial: Basic SSH Usage](https://docs.nexcess.com/hosting/server-administration/linux/what-is-secure-shell-ssh/) article will help you.

As a first step, identify the WordPress site you would like to move and where it is located. This is commonly known as the *“Document Root”* of the site. Next, identify the target location for the new site. Once you have decided on the new target location for the site move, you will need to create the new and different site via the cloning and moving steps provided.

In this article, we will be moving **growblop.com** to a subdomain called **staging.growblop.com**. The **WordPress Version** is **5.8.2.**

Once you are connected to the server by **SSH**, you will need to change to your WordPress site’s directory. We are going to change to its *“Document Root”* by issuing this command:

```
<strong>cd /home/growblop/public_html</strong>
```

You can view the files and directories under the *“Document Root”* by using the “ls” command:

```
<strong>ls /home/growblop/public_html</strong>
```

## Before Working With the Database

Before working with databases, you should review the related commands that are covered well on the page that documents [Developer Resources for WP-CLI Commands > wp db <command>](https://developer.wordpress.org/cli/commands/db/) to best understand the available options and details.

For your reference, **WP-CLI** has commands to reset and import a database:

```
<strong>wp db reset --yes</strong>
```

```
<strong>wp db import wp_growwpgrow_db_cloning.sql</strong>
```

As you review the steps below, consider using the most appropriate commands in the proper sequence.

## Working with Databases

Using your favorite text editor such as “Nano”, open up the settings file that would have the database configuration settings. If you are not sure how to use the Nano text editor, the [How to Install and Configure Nano on CentOS 8](https://www.liquidweb.com/blog/how-to-install-and-configuring-nano-on-centos-8/) article will help you.

You will see a file named **wp-config.php**. Using your favorite text editor (such as **Nano**) open up this file:

```
<strong>nano wp-config.php</strong>
```

Once you have this file opened, you will need to copy the **DB\_NAME** and store this somewhere temporarily. In this example, we have copied and temporarily stored the database name from the **wp-config.php** into a notepad page, so that we do not have to open the **wp-config.php** file again:

```
<strong>define( 'DB_NAME', 'wpgrow_db' );</strong>
```

You will need to make a database dump for this database. If you are not sure how to use the **mysqldump** command, the [How to Backup and Restore MySQL Databases from the Command Line](https://docs.nexcess.com/hosting/server-administration/database-management/mariadb-mysql/restoring-a-mysql-database-from-a-backup/) article will help you.

Let’s go ahead and make a database dump for the live database.

Change to this directory:

```
<strong>cd /home/growblop</strong>
```

Make the dump and call the dump **wpgrow\_db\_cloning.sql**:

```
<strong>mysqldump wpgrow_db > wpgrow_db_cloning.sql</strong>
```

## Cloning Your Site

Next, we will need to create the subdomain. If you are using a cPanel server, you will need to open up cPanel on your browser and navigate to **Domains >> Subdomains**, and create the new subdomain that you will use for the new WordPress site. Please take note of the ***“Document Root”*** location of the new subdomain.

We will need to use a method for syncing the files to the new **staging.growblop.com** *“Document Root”*. The most commonly used method is to use **rsync.** If you are not sure how to use the **rsync** command, the [Install Rsync and Lsync on CentOS, Fedora or Red Hat](https://www.liquidweb.com/blog/install-rsync-and-lsync-on-centos-fedora-or-red-hat/) article will help you. We will now issue this command:

```
<strong>rsync -avH /home/growblop/public_html/ /home/growblop/staging.growblop.com/</strong>
```

Now that the files are copied over to the new WordPress subdomain site, we will have to create a new database, a new database user, and the new database user’s password. If you are using a cPanel server, you will need to navigate to **DATABASES >> MySQL Databases**. Enter the new Database name in the box and click *“Create Database”*. Next, under the **MySQL Users**, enter the new database user and create a strong password with it. Click on *“Create User”*. Next, you will need to add the permissions for the new database user with the new database. Under the *“Add User To Database”*, choose the user and the database and click on the *“Add”* button. This will open a new page. Click on the *“ALL PRIVILEGES”* check box and click the *“Make Changes”* button.

You will need to open up the new WordPress site’s **wp-config.php** file and change the **DB\_NAME, DB\_USER**, and **DB\_PASSWORD** to the new database, user, and password that you just created:

```
<strong>nano wp-config.php</strong>
```

Do not forget to save the **wp-config.php** file and then close the **wp-config.php** file.

Now that the new database, user, and password are set in the **wp-config.php** file for the staging site. We can now import the live site’s database dump that we created. My new database is called **staging\_grow\_db.** To import the live WordPress site’s database dump file into the new WordPress site’s database, you will need to issue this command:

```
<strong>mysql staging_grow_db < /home/growblop/wp_growwpgrow_db_cloning.sql</strong>
```

We are not done yet. We still need to update all of the domain URL links in the database. The easiest way is to use the **WP-CLI** utility.

Change to the **staging.growblop.com** *“Document Root”*:

```
<strong>cd /home/growblop/staging.growblop.com</strong>
```

It is best practice not to use the **WP-CLI** while being the root user. If you are connected with the root user with **SSH**, you will need to change to the domain user. In this case the domain username is **growblop**:

```
<strong>su growblop</strong>
```

Now that we have switched to the **growblop** user in our **SSH** terminal, we can run this command using the **WP-CLI** to update all of the URLs in the new database:

```
<strong>wp search-replace '://growblop.com' '://staging.growblop.com' recurse-objects --skip-columns=user_email,guid --all-tables</strong>
```

The command above changes all of the instances of **http://growblop.com** or **https://growblop.com** to be **http://staging.growblop.com** or **https://staging.growblop.com** in the database.

```
<strong>wp rewrite flush</strong>
```

The command above rewrites the permalinks (flushes them) after search-replace has been run, and is well covered on the page that documents [Developer Resources for WP-CLI Commands > wp rewrite flush](https://developer.wordpress.org/cli/commands/rewrite/flush/) with regard to the available options and details.

Congratulations! You have just cloned and moved your site.
