Ubuntu 24.04
Sponsored Link

Apache2 : Virtual Hostings2024/05/17


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].
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

a2ensite virtual.host

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

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.
mkdir /var/www/virtual.host

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