How To Set Up Apache Virtual Hosts on Ubuntu

To create the new Virtual Host File on the apache, you need to set up the apache configuration. It's good idea to create duplicate file rather than creating new. Here is how to do so
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/
Open the newly created configuration file.
sudo nano /etc/apache2/sites-available/
Edit server details of your domain.
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
Now, create shortcut of apache host file.
sudo a2ensite example.com
Retart apache
sudo service apache2 restart
based on digital ocean vps experience