Migrate WordPress Staging Site to Production Site

Whenever you create a WordPress website with WP STAGING, there often comes the time that you want to migrate WordPress to your production website.
In that step-by-step guide, I’ll show you how to migrate WordPress to your production website manually without using any extra tool.

If you like to migrate, WordPress automatically with
WP STAGING | PRO and not do that process manually; read that article.

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

This tutorial explains how to migrate your site manually using the WP STAGING basic version.

Read the instructions below very 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 get started using WP Staging free version to convert the staging site to the production one.

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

Limitations: Contrary to the use of WP STAGING | PRO, the manual process makes your staging site unavailable, and you need to create a new one after finishing the whole 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 Better Search Replace activated on live site.
    (Not needed with WP STAGING | PRO)
  • A backup software installed on the live site. That is not necessary with WP STAGING | PRO as it already includes one of the most powerful and modern backup solutions. (Faster and with less CPU load than many other  backup plugins)

 

Please read this entire inwstruction 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

At 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 having a look at WP STAGING | PRO. It already includes one of the most sophisticated backup solutions.

Note: At the file selection of your backup plugin, make sure to select and include the subfolder of the staging site. That is necessary to back up your staging site. Also, include 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 clone the entire staging site automatically to live by clicking one button only.
  • Option 2 – Easy: Go this route and do some manual search & replace operation 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 over to the original database tables anytime in case 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 not be available any longer, and you need to create a new one.

At 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 strings leading to the live site.

Fortunately, we can use an excellent plugin to do this step without the need for manual interaction. If you haven’t already installed the plugin  Better Search Replace

Next, Go to Tools > Better 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 which begin with the table prefix of the staging site. 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, you need to 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 the process without changing any real data and is a good indicator if 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 to the end, 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 if a database table belongs to the staging site or the live site. That is used by WP Staging to show the authentication screen.

Use a database administration tool of your choice, 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.

For this, 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:

This 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 need to create a new staging site when you are done.
The old staging site cannot be used any longer!

Congratulation! You 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 pays our bills and also comes with top-notch support!😊