[root@kvm5 ~]# egrep -v '(#|^$)' /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf <VirtualHost *:@@Port@@> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "@@ServerRoot@@/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "/var/log/httpd/dummy-host.example.com-error_log" CustomLog "/var/log/httpd/dummy-host.example.com-access_log" common </VirtualHost> <VirtualHost *:@@Port@@> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "@@ServerRoot@@/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "/var/log/httpd/dummy-host2.example.com-error_log" CustomLog "/var/log/httpd/dummy-host2.example.com-access_log" common </VirtualHost>
[root@kvm5 ~]# vim /etc/httpd/conf/httpd.conf [root@kvm5 ~]# tail -8 /etc/httpd/conf/httpd.conf <Virtualhost *:80> Documentroot /var/www/html Servername kvm5.deyu.wang </Virtualhost> <VirtualHost *:80> DocumentRoot /var/www/virtual ServerName www5.deyu.wang </VirtualHost>
[root@kvm5 ~]# systemctl restart httpd.service
[root@kvm5 ~]# mkdir /var/www/virtual [root@kvm5 ~]# wget http://dywang.csie.cyut.edu.tw/materials/virtual.html -O /var/www/virtual/index.html
[root@kvm5 ~]# chown deyu1 /var/www/virtual
[root@kvm5 ~]# curl http://kvm5.deyu.wang web test [root@kvm5 ~]# curl http://www5.deyu.wang virtual test