Hey friend,
Let’s say domain1.com is a Wordpress at /var/www/html and you want domain2.com to host a copy of the same installation. Let’s also say these values are true for domain1.com’s Wordpress instance, all of which can be found in wp-config.php:
Database name: wordpress
Database user: wordpress
Database pass: 12345
Here’s what I’d do:
mkdir /var/www/domain2
cp -R /var/www/html/* /var/www/domain2
mysql
create database domain2;
grant all on domain2.* to domain2 identified by '54321';
quit
mysqldump wordpress > /root/wordpress.sql
mysql domain2 < /root/wordpress.sql
chown -R www-data. /var/www/domain2
In this example I set these values for you to change in /var/www/domain2/wp-config.php:
Database name: domain2
Database user: domain2
Database pass: 54321
Obviously use better passwords than I did in this example. Next you have to change domain1.com to domain2.com in the Wordpress configuration, and you can find a few different ways to do that here:
https://codex.wordpress.org/Changing_The_Site_URL
You already mentioned that you have no problem configuring the virtual hosts, but just a quick reference for anyone else reading later:
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04
Hope that helps :)
Jarland

by Brennen Bearnes
The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 16.04 server.