Virtual hosts let you serve multiple websites from a single Apache server.
Create a Virtual Host
Create /etc/apache2/sites-available/example.com.conf:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/html
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>Create Web Root
mkdir -p /var/www/example.com/html
echo "<h1>Hello from example.com</h1>" > /var/www/example.com/html/index.html
chown -R www-data:www-data /var/www/example.comEnable the Site
a2ensite example.com.conf
systemctl reload apache2