一、虚拟主机 配置 1、基于ip 要求:通过192.168.32.31可以访问/var/www/html目录内容,通过192.168.32.32可以访 问/var/www/virt目录内容 [root@station1 ~]#vi /etc/httpd/conf/httpd.conf VirtualHost 192.168.32.31:80 ServerAdmin DocumentRoot /var/ww
一、虚拟主机
配置 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】
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn