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.
- sudo mkdir -p /var/www/clone
- 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.:
- 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:
Enter password when asked and press ENTER.
Create database:
- CREATE DATABASE wordpressclone DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
And create new user or give privileges to existing one:
- GRANT ALL ON wordpressclone.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
Update privileges:
Exit MySQL prompt:
Make a backup of current database:
- mysqldump -u root -p wordpress > ~/wordpress.sql
This will create database dump in your home folder.
Open it with any text editor:
And on top of it add:
Save it and exit editor.
Run that file using:
- mysql -u root -p < ~/wordpress.sql
For last step we need to update WordPress clone config.
Open wp-config.php
for clone:
- 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 :)