Ubuntu 22.04
Sponsored Link

Apache2 : Virtual Hostings2022/05/10

 
Configure Virtual Hostings to use multiple domain names.
[1] For example, Add a new Host setting that domain name is [virtual.host], document root is [/var/www/virtual.host].
root@www:~#
vi /etc/apache2/sites-available/virtual.host.conf
# create new
# settings for new domain
<VirtualHost *:80>
    DocumentRoot /var/www/virtual.host
    ServerName www.virtual.host
    ServerAdmin webmaster@virtual.host
    ErrorLog /var/log/apache2/virtual.host.error.log
    CustomLog /var/log/apache2/virtual.host.access.log combined
</VirtualHost>

root@www:~#
a2ensite virtual.host

Enabling site virtual.host.
To activate the new configuration, you need to run:
  systemctl reload apache2

root@www:~#
systemctl reload apache2

[2] Create a test page and access to it from any client computer with web browser. That's OK if following page is shown.
root@www:~#
mkdir /var/www/virtual.host

root@www:~#
vi /var/www/virtual.host/index.html
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Virtual Host Test Page
</div>
</body>
</html>
Matched Content