CentOS 7
Sponsored Link

Apache httpd : Virtual Hostings2014/07/23

 
Configure Virtual Hostings to use maltiple domain names.
The example below is set on an environment which the domain name is [srv.world], virtual domain name is [virtual.host (root directory[/home/cent/public_html])].
It's necessarry to set Userdir settings for this example, too.
[1] Configure Virtual Hostings.
[root@www ~]#
vi /etc/httpd/conf.d/vhost.conf
# create new

# for original domain

<VirtualHost *:80>
   DocumentRoot /var/www/html
   ServerName www.srv.world
</VirtualHost>
# for virtual domain

<VirtualHost *:80>
   DocumentRoot /home/cent/public_html
   ServerName www.virtual.host
   ServerAdmin webmaster@virtual.host
   ErrorLog logs/virtual.host-error_log
   CustomLog logs/virtual.host-access_log combined
</VirtualHost>
[root@www ~]#
systemctl restart httpd

[2] Create a test page and access to it from a client computer with a web browser. It's OK if following page is shown.
[cent@www ~]$
vi ~/public_html/virtual.php
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Virtual Host Test Page
</div>
</body>
</html>
Matched Content