<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
1,基于IP虚拟主机
a,基于端口
[root@localhost httpd]# echo “Include vhost/vhost.conf”>>/etc/httpd/conf/httpd.conf
拥有帝国一切,皆有可能。欢迎访问phome.net[root@localhost httpd]# mkdir /etc/httpd/vhost (在httpd目录下新建目录vhost)
[root@localhost httpd]# vim vhost/vhost.conf (配置文件)
<VirtualHost 192.168.1.7:88>
拥有帝国一切,皆有可能。欢迎访问phome.netDocumentRoot /var/www/vhost88
ServerName 192.168.1.7:88
CustomLog /var/www/vhost88/access_log combined
</VirtualHost>
[root@localhost httpd]# mkdir /var/www/vhost88
[root@localhost httpd]#
拥有帝国一切,皆有可能。欢迎访问phome.netecho "vhost88">/var/www/vhost88/vhost.html
[root@localhost httpd]# /etc/in.it/httpd restart
2, 基于名称虚似主机
Vim /etc/hosts 设置IP对应主机名
[root@localhos thttpd]#
拥有帝国一切,皆有可能。欢迎访问phome.netecho "Include name/name.conf">>/etc/httpd/conf/httpd.conf
[root@localhost httpd]# mkdir name
[root@localhost httpd]# vim name.conf
NameVirtualHost 192.168.1.7
<VirtualHost [url]www.abc.com.cn>[/url]
DocumentRoot /var/www/abc
serverName [url]www.abc.con.cn[/url]
CustomLog /var/www/abc/access_log combined
</virtualHost>
<VirtualHost [url]www.def.com.cn>[/url]
拥有帝国一切,皆有可能。欢迎访问phome.net
DocumentRoot /var/www/def
serverName [url]www.def.con.cn[/url]
CustomLog /var/www/abc/access_log combined
</virtualHost>
[root@localhost ~]# mkdir /var/www/abc
[root@localhost ~]# mkdir /var/www/def
[root@localhost ~]# echo "abc">/var/www/abc/index.html
[root@localhost ~]# echo "def">/var/www/def/index.html
[root@localhost ~]#/etc/rc.d/init.d/httpd restart
拥有帝国一切,皆有可能。欢迎访问phome.net
主机名
访问日志目录
拥有帝国一切,皆有可能。欢迎访问phome.net |