Question

Make clone from my site on same droplet, for testing purposes, with separate database and files, is it possible and how please?

Hi, as the title says i want to make clone from my wordpress website on the same droplet, but in different directory and database so i can test plugins and other coding stuff. Can you help me please? Thanks


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Yes, that would be possible.

Let’s assume following setup: You have WP in /var/www/html WP database is called wordpress User for that database is wordpressuser identified by password.

First you need to copy html directory somewhere else. Let’s create folder clone under www and copy html there.

  1. sudo mkdir -p /var/www/clone
  2. sudo cp -r /var/www/html /var/www/clone/

Enter clone and verify you have html with files there.

Make sure permissions are right, i.e.:

  1. sudo chown -R $USER:$USER /var/www/clone/html

Verify WP permissions too.

If everything is there, we need to setup Apache to use it. I would setup a subdomain for it.

We will make subdomain test for it. Make CNAME record in DNS settings test @.

Now, we need Apache Virtual Host. This tutorial will help you. Basically, as you already have directory setup, just create second VHost and enable it.

You need to “clone” database. First create new database and give privileges to it. Login to MySQL:

  1. mysql -u root -p

Enter password when asked and press ENTER.

Create database:

  1. CREATE DATABASE wordpressclone DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

And create new user or give privileges to existing one:

  1. GRANT ALL ON wordpressclone.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Update privileges:

  1. FLUSH PRIVILEGES;

Exit MySQL prompt:

  1. EXIT;

Make a backup of current database:

  1. mysqldump -u root -p wordpress > ~/wordpress.sql

This will create database dump in your home folder. Open it with any text editor:

  1. nano ~/wordpress.sql

And on top of it add:

  1. USE wordpressclone;

Save it and exit editor. Run that file using:

  1. mysql -u root -p < ~/wordpress.sql

For last step we need to update WordPress clone config. Open wp-config.php for clone:

  1. nano /var/www/clone/html/wp-config.php

Make sure you set database name to wordpressclone and verify user used for it. Save it and exit. Go to http://test.example.com/wp-login.php. Login, go to Settings -> General, update URLs, save and you are good to go.

Good luck, I hope this will work for you, if you have any questions or problems, ask, we will try to help you :)

Just one question, how the variables for the PATH in the database changed ? I mean the path to the images and stuff, i really don’t get that. Please post some link so i can learn a little bit :)

Omg!!! Thanks man, you saved me a lot of headaches, for days i was trying to make this work. At first i tried www.example.com/testsite but i was having so much trouble with importing the database, tried duplicator but it was not working, and on my local PC it worked but that is another story :) . I was sceptical for using the USE wordpressclone; because i didn’t know what will happen, but i know that i learned so much from your help!!!
I know that your guide will ease so much headaches for other people too :))) Thanks again and have a nice day!!!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel