Fedora 39
Sponsored Link

Apache httpd : Virtual Hostings2023/11/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].
[root@www ~]#
vi /etc/httpd/conf.d/vhost.conf
# create new
# settings for original domain

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName www.srv.world
</VirtualHost>

# settings for new domain
<VirtualHost *:80>
    DocumentRoot /var/www/virtual.host
    ServerName www.virtual.host
    ServerAdmin webmaster@virtual.host
    ErrorLog logs/virtual.host-error_log
    CustomLog logs/virtual.host-access_log combined
</VirtualHost>

<Directory "/var/www/virtual.host">
    Options FollowSymLinks
    AllowOverride All
</Directory>

[root@www ~]#
mkdir /var/www/virtual.host

[root@www ~]#
systemctl reload httpd

[2] Create a test page and access to it from any client computer with web browser. It's OK if following page is shown.
[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