Don't wait… it will take me some time…

How to Create a Development Environment or Clone your WordPress

How to Create a Development Environment or Clone your WordPress Blog

  1. Create a subdomain for your dev site… this will create a new folder under the public_html folder (e.g. public_html/dev)
  2. Zip everything inside your source domain folder
    • If it’s not a subdomain, that will be all the files inside /public_html
    • If it’s a subdomain, it will be all the files inside the subdomain folder (e.g./public_html/<subdomain>).
    • Remember to download a copy of the zipped file in your local directory so you’ll have a backup
  3. Unzip the source domain files inside the DEV folder (e.g. public_html/dev)
  4. Backup database of main blog

HOW?

    • Scroll down to the Databases section and select phpMyAdmin

How to Create a Development Environment 1 How to Create a Development Environment or Clone your Wordpress

    •  Inside PhpMyAdmin, select the database of your main blog from the left side bar
    • Click on the Export tab, click Go and specify the filename in your local directory

export database How to Create a Development Environment or Clone your Wordpress

NOTE: Open the backed up SQL in your computer and comment out create and use lines inside the backed up sql script if there’s any

How to Create a Development Environment 3 How to Create a Development Environment or Clone your Wordpress

5. Create new database from inside the cpanel

    • Scroll down to the Databases section and select MySQL Databasewizard

How to Create a Development Environment 4 How to Create a Development Environment or Clone your Wordpress

    •  Enter the database name and create the user name and password for it.

6. Go back to Home in Cpanel, and under Databases, click phpMyAdmin.
7. Inside PhpMyAdmin, and import the backed up sql in the new database
How?

    • Inside PhpMyAdmin, select the newly created database from the left side bar
    • Click on the import tab and select the sql file that you backed up earlier

How to Create a Development Environment 5 How to Create a Development Environment or Clone your Wordpress

8. Click “Go” and you will see the database tables created.
9. Open the wp_option table and edit the option siteurl

    • replace the option_value to the correct subdomain url

How to Create a Development Environment 6 How to Create a Development Environment or Clone your Wordpress

10. If your posts have images in them, the link will most likely have the old URL. You can change them by running the following query below. This SQL will search and replace a string within a field:

UPDATE [table name] SET [field name] = replace([field name],‘[string-to-find]’,'[string-that-will-replace-it]’)

WHERE INSTR([field name], ‘[string-to-find]’) > 0;

update table set field = replace(field, ‘foo.com’, ‘dev.foo.com’) where instr(field, ‘foo.com’) > 0;

e.g.

update wp_posts set post_content = replace(post_content, ‘foo.com’, ‘dev.foo.com’) where instr(post_content, ‘foo.com’) > 0;

If there menus that needs to be updated, you need to update the wp_postmeta table, e.g.

update wp_postmeta set meta_value = replace(meta_value, 'foo.com', 'dev.foo.com') where instr(meta_value, 'foo.com') > 0;

11. Open wp-config.php in your dev folder (e.g. /public_html/dev/wp-config.php) and change the values for the following database parameters below then save:

    • DB_NAME
    • DB_USER
    • DB_PASSWORD

How to Create a Development Environment 7 How to Create a Development Environment or Clone your Wordpress

Voila! You should now be able to see the cloned website in the new subdomain that you created.

2 Responses to “How to Create a Development Environment or Clone your WordPress”

  1. Claudette says:

    Easy to follow and it works! made my day. Thank-you!

  2. Hands down the easiest most succinct and accurate way to do this! You rocked it!

Leave a Reply

Powered by WordPress | Designed by Elegant Themes