Can I clone WP to another directory on the same server?

I want to do some changes on WP for a friend but I don't want to do it live. So I was thinking of cloning the current WP to another directory on the same server and then do work on that version (www.myfriendswp.com -> www.myfriendswp.com/testing) and, when done, clone the changes back to main directory.

Is this possible or will there be some problems? Most tutorials and plugins are talking about cloning to a different server.

Topic clone-site installation Wordpress

Category Web


Yes you can clone the website on the same server in another directory . You may follow below steps.

  1. Copy entire wordpress root directory in another folder for ex. Beta.
  2. Create a new DB and copy the existing database into the new DB . You can use same DB by changing WP prefix but I would recommend having a new DB.
  3. Change the db details in wp-config.php files.

If you have any doubts in above please let me know . I will guide you for the same


I would recommend to clone it on a subdomain. Something like "testing.myfriendswp.com". I have tried this approach and it works fine. If you have a cpanel, you will see an option to create a subdomain in it. create a subdomain and point it to a folder inside public_html. So, for example, your subdomain "testing.myfriendswp.com" will be pointed to a directory "public_html/testing". Once you have the subdomain created:

  1. copy the WP files from the main domain to subdomain
  2. create a new database and import tables from the main DB to it.
  3. set appropriate DB credentials in wp-config.php file
  4. change the domain name in the wp-options table in the new DB.
  5. boot up WP on the subdomain and refresh the permalink settings.
  6. Run a search replace script on DB to replace main domain to the subdomain.

For extra security, add a robots.txt file on your subdomain to prevent the instance from being crawled by Search Engine Robots.

Thanks

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.