A、虚拟主机配置
1、基于ip
要求:通过192.168.32.31可以访问/var/www/html目录内容,通过192.168.32.32可以访 问/var/www/virt目录内容
[root@station1 ~]#vi /etc/httpd/conf/httpd.conf
ServerAdmin
DocumentRoot /var/www/html
ServerName 192.168.32.31:80
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
ServerAdmin
DocumentRoot /var/www/virt
ServerName 192.168.32.32:80
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
2、基于端口
要求:通过192.168.32.31的80端口可以访问/var/www/html目录内容,通过192.168.32.31的8080端口可以访问/var/www/virt目录内容
[root@station1 ~]#vi /etc/httpd/conf/httpd.conf
Listen 80 #此端口配置文件默认就有
Listen 8080 #手动添加此端口
ServerAdmin
DocumentRoot /var/www/html
ServerName 192.168.32.31:80
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
ServerAdmin
DocumentRoot /var/www/virt
ServerName 192.168.32.31:8080
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
3、基于主机头
要求:通过station1.kvm.com可以访问/var/www/html目录内容,通过可以访问/var/www/virt目录内容 (注意要求DNS服务器上有这两个网站解析)
[root@station1 ~]#vi /etc/httpd/conf/httpd.conf
NameVirtualHost 192.168.32.31:80 #要求必须由此行,此行表示打开主机头虚拟主机
ServerAdmin
DocumentRoot /var/www/html
ServerName station1.kvm.com
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
ServerAdmin
DocumentRoot /var/www/virt
ServerName
ErrorLog logs/dummy-host.kvm.com-error_log
CustomLog logs/dummy-host.kvm.com-access_log common
[1] [2] 下一页
【责编:peter】