WorPress: howto prepare a test site to avoid contaminating the production environment

in wordpress •  5 years ago  (edited)

WP-development-1080x750.webpYes, but why?

While preparing my website (https://taller42.org), I decided to prepare a test site for experiments, leaving the production site intact until the desired structure was found.

The operation itself is quite simple, it is about copying the content of the Wordpress installation to another domain, creating a database and moving all data from one to another.

I want to clarify that what I will write is addressed to advanced users / sysadmin who know how to complete the operations described; if you do not know what and how you are doing the advice is to contact a person who has the skills and knowledge to do what is necessary.

For my convenience I prefer to create a third-level domain (for example test.foo.org compared to foo.org) in order to take advantage of space and band already paid by the customer; once equipped with any FTP client let’s get started:

let’s download on our computer a full copy of the folder where wordpress resides, we make a .zip file and we put it to safety (you never know what can happen: D), and then we load the whole on the installation folder of the test site
now we have to duplicate the database, this is also relatively simple; taken for granted that you have already prepared the database and its user, simply dump mysql (export) and then import it into the new database
at this point the “siteurl” and “home” values must be modified in the “
_options” table (instead of the asterisk there will be the prefix of the db you chose when creating it); in theory they should be set to foo.org and we have to change them to test.foo.org; the provider to which I support allows the administration of the db through phpmyadmin, but the change can be done in the way that we feel more comfortable
the last operation is the one that allows to correctly point to the test site: it is necessary to modify the wp-config.php file in the root of the site; here is the piece of code involved:
// ** MySQL Settings – You can get this information from your hosting provider ** //

/** The name of the WordPress database */
define(‘DB_NAME’, ‘name_db’);

/** MySQL database user name */
define(‘DB_USER’, ‘user_db’);

/** Password of the MySQL database */
define(‘DB_PASSWORD’, ‘password_db’);

/** Hostname MySQL */
define(‘DB_HOST’, ‘localhost’);

/** Database Charset to be used in creating tables */
define(‘DB_CHARSET’, ‘utf8’);

/** The type of collation of the database. Do not change if you have no idea what it is. */
define(‘DB_COLLATE’, ”);

Said, done, our test site should be online, in case any wordpress continues to point to the production site and not to the test site, it is useful to reset the browser cache, reload the page and make sure that in the address bar of the browser you can see the address test.foo.org and not foo.org

One more thing (cit.):

Remember the permalink! After having carried out these changes, the permalinks must also be rebuilt, the simplest method is to go to the admin / modify permalink mask (test.foo.org/wp-admin/options-permalink.php to stay at the first nomenclature) and choose to change the structure. In case we want to go back to the one selected before, we recreate and go back.

That’s all! Stay Tuned!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!