Create a WP staging website in 6 steps w/o a Plugin

This tutorial assumes you have some prior knowledge of PHPmyAdmin, adding Domains, and copying files.

How-to Create a WP Staging Website:

1. First thing you need to do is to create a subdomain (subdomain.example.com). This allows your staging website to run in a separate folder, not affecting your main website files.

vestacp
VestaCP

2.Now that you have setup your subdomain, the next step is to copy the database from your live site to your staging site.

Log into phpMyAdmin, and select your current live database, clicking on the Operations tab in the menu bar.

phpMYAdmin
phpMYAdmin

In the Copy Database To box, enter the name of your staging database (if you haven’t created it yet, click “CREATE DATABASE before copying”). Click Go to run the copy, this could take longer on larger databases.

Copy database
Copy database

3. After your database has copied, you need to select it from the sidebar on the left and rename the URLs in the database. To do this, click on the SQL tab in the menu bar and add the code below to Run SQL queries.

SQL
SQL

Remember to update the URL value: NEW_URL = staging.example.com, ORIGINAL_URL = example.com

UPDATE wp_options SET option_value = REPLACE(option_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET guid = REPLACE(guid, 'ORIGINAL_URL', 'NEW_URL');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'ORIGINAL_URL', 'NEW_URL');

4. After copying your database, you need to copy your WordPress files to the staging server.

5. After copying your data, update your wp-config.php file to use your new staging database connection details. You can use FTP to accomplish this, or if you are an expert, you can use Terminal:

cp -a /PATH/TO/INSTALL /PATH/TO/STAGING

6. Remember to add a disallow all to your robots.txt, and/or update your Search Engine Visibility settings or you might be penalized with duplicate content.

Settings > Reading > Search Engine Visibility

Click “Discourage search engines from indexing this site”

Isaac Adams-Hands

Full Stack Developer, Digital Marketer, and InfoSec enthusiast. He received his Bachelor’s Degree from the University of Western Sydney and his Business Diploma from Georgian College before joining various marketing positions in search portals, e-commerce, higher education, and addiction recovery services.

Follow @ twitter

Related posts

CSS order

Here is how to load a WordPress child theme’s CSS after the parent theme’s CSS. The trick here is to add a 1 to the add_action script, illustrated below Functions.php Find and edit this little bit of code in the Functions.php file: This way your Parent’s CSS loads first, and your Child theme will load… Read More

How to add a header image in WP

Here is a quick example of how to add a background image to the header of your WordPress website pulling the Feature Image Featured Image Code: You could also use: