Migrate WordPress Staging Site to Production Site

When you create a WordPress website using WP STAGING, there often comes a time when you want to migrate WordPress to your production website.
This step-by-step guide will show you how to manually migrate WordPress to your production website.

Please make sure you are tech savvy and know how to work with databases and files. Although this tutorial is easy to follow, it is much easier to push the staging site with the PRO version as it offers the “push changes” function with one click.

So, if you want to automatically copy your WordPress staging site with one click using WP STAGING | PRO, read this article instead.

How to Convert WordPress Staging Site to Production Site with WP STAGING basic version

This tutorial explains migrating your site manually using the WP STAGING basic version.

Read the instructions below carefully, and do not miss any of the mentioned steps, as it could make your website unavailable!

If you don’t want to do the steps manually, watch the video below on how WP STAGING | PRO can push your staging site to your production website.

Suppose you use the WP STAGING free version and don’t want to become a pro user; you can use the instruction on this page to convert the staging site to the production site. Let’s start using WP Staging free version to copy the staging site to the production one.

Goal: After reading this tutorial, you can convert your existing staging site to a production website.

Limitations: Contrary to WP STAGING | PRO, the manual process makes your staging site unavailable, and you need to create a new one after finishing the process.

How to Move Over Complete Staging Site to Production

Requirements for this tutorial:

  • One live site which is in production use, e.g., https://host.com
  • You previously created one staging site with WP STAGING or WP STAGING | PRO. The staging site is in a subfolder like https://host.com/staging.
  • Plugin WP STAGING activated on live site.
  • Plugin Search And Replace is activated on the live site.
    (Not needed with WP STAGING | PRO)
  • A backup plugin is installed on the live site. That is not necessary if you already use WP STAGING. It already comes with one of the most efficient and modern backup solutions. (Faster and with less CPU load than many other  backup plugins)
Please read this instruction and try to understand it before you do any work or even harm your production website by missing out on any steps!

1. Step – Backup Live and Staging Site

First, backup the entire production and staging site with a backup tool of your choice.

If you have a huge site with millions of database rows or want to prevent spikes of loading time while creating a backup, consider looking at WP STAGING | PRO. It already includes one of the most sophisticated backup solutions.

Note: At the file selection of your backup plugin, select and include the subfolder of the staging site. That is necessary to back up your staging site. Also, select all database tables beginning with the prefix wpstg_

2. Step – Copy Files

Use an FTP program like FileZilla and copy over the folders wp-content/uploads, wp-content/plugins and wp-content/themes from your staging site subfolder to the production site.

3. Step – Migrate the Database

You have three options to migrate the database data of the staging site so that the production site’s Database will use it:

  • Option 1: – Very easy:  Use WP STAGING | PRO and automatically clone the entire staging site to live by clicking one button.
  • Option 2 – Easy: Go this route and do some manual search & replace operations in the staging site database tables and tell WordPress to use the staging database tables for the production site. The live site’s database tables will not be overwritten, nor will any of its data be deleted. You can switch to the original database tables anytime if something is not working as intended. Read step 3.1
  • Option 3 – Advanced: Use a separate DB migration plugin like wp migrate DB or any other plugin that can migrate the staging site database to live.

3.1. Convert Staging DB Tables to Live Database

That is the easiest way and most recommended if you do not care that the live site will use the staging site database tables after the conversion process.

Note: After doing that, your staging site will no longer be available, and you need to create a new one.

First, you need to do a search and replace the staging database tables.

Find all strings containing the path to the staging site and replace them with paths pointing to the live site.

Fortunately, we can use an excellent plugin to do this step without requiring manual interaction. If you haven’t already, install the plugin  Search And Replace

Next, Go to Tools > Search & Replace.

We assume that your staging site is located at http://yoursite.com/staging.

You can test this by opening the staging site and checking the complete URL in the browser window.

  • Enter the following string into the search for the input field
//mysite.com/staging

Enter the string below into the Replace with field

//mysite.com

Make sure to work accurately. Enter exact strings!

– Do not enter any trailing slash after the URL!
– Do not add HTTP:// or https:// to the search string

Any misspelling will lead to a broken staging or even live site.

Next, select all the tables that begin with the staging site’s table prefix. Usually, these tables begin with the prefix wpstg[0]_

You can find out the correct table prefix by looking into the list of staging sites:

If you are using an older version of WP STAGING, check out the table prefix by looking into the wp-config.php of the staging site:

To do so, open the file below by logging in with FTP to your website:

path_to_wordpress/staging_name/wp-config.php
Do not select any other tables!
All other tables belong to the live site or to other staging sites, which must not be altered in any way!

In the next step, you can select the dry-run option. That allows us to run the search and replace process without changing any real data and is a good indicator of whether the provided settings are correct and if the search and replace plugin is working as expected.

Click on the Run Search/Replace button.

If the dry-run has been run successfully, deselect the dry-run option and run the search and replace process again.

Remove database value wpstg_is_staging_site

The next step is to delete the Database’s value, which defines whether a site is a staging site or a main live production website. WP Staging uses that value to show the authentication screen.

Use a database administration tool, e.g., PHPMyAdmin or adminer, and search the staging site’s database tables for the value:

wpstg_is_staging_site

Delete this value or set it to false.

If you did this successfully, you need to finish another step, and you are done:

Alter wp-config.php

The last step is to tell the WordPress live site to use the staging site’s database tables.

You need an FTP account to access your website and an FTP client. I recommend the use of FileZilla. It’s entirely free and open source.

Login to your live website with the FTP client program and open your live site’s config file.
The file is located in /path/to/wordpress/wp-config.php

wp-config.php

Open the file in edit mode by opening the context menu with the right mouse button and select edit

Change the value of $table_prefix to the same value that is used by the staging site, e.g.

$table_prefix = 'wpstg1_';

The result in your editor will look like this:

That tells your production site to use all the database tables of the staging site.

Now open the live site, and you will see that it displays all the content from the staging site.

If you like to enable permalinks, you need to login to the admin dashboard and enable permalinks from Settings > Permalinks.

Now, the live site uses the staging site database, and all the content from the staging site has been moved over to the live site.

The last step is to delete the old staging subfolder by using FTP:

path/to/wordpress/staging-name

Important: As the production site will use the staging site database tables, you must create a new staging site when done.
The old staging site cannot be used any longer!

Congratulation! You’ve successfully migrated your staging site to live.

If you want to save time and like to get the steps done fully automatically, please consider purchasing WP STAGING | PRO.
The pro version covers our development expenses and comes with top-notch support!😊