Whenever you upgrade a site with any new software, it is strongly recommended to make a test-copy of the site, and to try the new software there before deploying it to the main live site. It is also very handy to have a test-copy to troubleshoot a problem, and/or to let support personnel login in order for them to see exactly the same screens as you are seeing, instead of making tons of screenshots and writing a handful of paragraphs explaining how to reproduce your problem. Below are a few tips on how to simplify making a test-copy.
- Review your hosting provider documentation on how to create a subdomain like
test.yourdomain.com
. It should not cost any extra money. Alternatively, you may run a test copy from a subfolder of the main site. - Review WordPress documentation on how to run WordPress from a different directory in case you decide to do so.
- Once a placeholder for a test-copy of your site is ready, use plugin Duplicator to copy the content of your site and its database to the new place. Plugin Duplicator has an excellent help documentation.
- It is a good idea to put the whole test site under a password (using .htaccess), so that it never gets memorized by search engines.
- You can use the test-copy for your own troubleshooting without a risk to break anything at the main site. It is also safe to give us an admin access to your test site to simplify troubleshooting.
- You may find many plugins, which help to duplicate a site, besides Duplicator, for example, WP Clone by WP Academy or All-in-One WP Migration. Let us know which one works better for you.
Before plugins like Duplicator existed, we used these manual steps:
- Log in to access your database (phpmyadmin)
- Select your database (if necessary) – Choose Export
- Use standard.
- Format = SQL and choose “Start”
- Save this file.
- On the server where you want the test site make a new empty database.
- Then go through phpmyadmin to this new database and select it.
- Via the Import button you now import the file that you had just saved.
Then copy all the files from your WP website (with FTP) to the new location on your server. (As an example to folder yoursite.com/test_copy)
- You have to change your
wp-config.php
file with the details of the new database – username – password – etc. - Change your
.htaccess
file as in example shown below:
From:# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
To:
# BEGIN WordPress RewriteEngine On RewriteBase /test_copy/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /test_copy/index.php [L] # END WordPress
Set the appropriate folders (uploads) and .htaccess file with chmod in the way you want them (755 is good).
- Then copy the file search_and_replace.php (download here) to the root of your WP installation in the folder test_copy.(unzip the downloaded file first)
- With the browser you go to:yoursite.com/test_copy/search_and_replace.php
- You will see a page that lets you change the necessary data in the database. (Only the website root, change yoursite.com to yoursite.com/test_copy)
- Note, this must be done carefully a typo is easily made.
- http and www must not be used because some hosts here otherwise deal with it.
- What is important for you to do only the necessary change, then the rest goes automatic.
- Let search and change it …. if it’s good then that’s all.
IMPORTANT: delete then the file search_and_replace.php