Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7347297
  • 博文数量: 1763
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16217
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1763)

文章存档

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: LINUX

2008-02-27 09:43:58

1.基于相同IP不同Port的虚拟主机
  
  1)vi /etc/http/conf/httpd.conf
  
  2)将Listen字段改为
  Listen 80
  Listen 8888
  (以上设置表示使用80以及8888端口)
  
  3)更改虚拟主机部分为:
  
  DocumentRoot /var/www/html/website1
  

  
  DocumentRoot /var/www/html/website2
  

  
  4)保存以上设置
  
  5)创建目录以及页面文件:
  #mkdir –p /var/www/html/website1
  #mkdir –p /var/www/html/website2
  #cd /var/www/html/website1
  #cat >index.html <  >website1
  >EOF
  #cd /var/www/html/website2
  #cat >index.html <  >website2
  >EOF
  
  (注:在/etc/httpd/conf/httpd.conf中有DirectoryIndex index.html index.html.var,表示只读index.html,而不读index.htm,切记)
  
  6)service httpd restart
  
  完成以上设置后,可以通过以下方式访问:
  
  1)打开浏览器
  
  2)输入以及
  
  2.基于相同Port不同IP的虚拟主机
  
  1)不同IP地址的配置:
  #cd /etc/sysconfig/network-scripts
  #cp ifcfg-eth0 ifcfg-eth0:1
  #vi ifcfg-eth0:1
  将eth0:1更改为:
  DEVICE=eth0:1
  ONBOOT=YES
  BOOTPROTO=static
  IPADDR=192.168.0.2
  NETMASK=255.255.255.0
  
  2)service network restart
  
  3)vi /etc/httpd/conf/httpd.conf
  
  4)更改虚拟主机部分为:
  
  DocumentRoot /var/www/html/website1
  

  
  DocumentRoot /var/www/html/website2
  

  
  5)创建目录以及页面文件:
  #mkdir –p /var/www/html/website1
  #mkdir –p /var/www/html/website2
  #cd /var/www/html/website1
  #cat >index.html <  >website1
  >EOF
  #cd /var/www/html/website2
  #cat >index.html <  >website2
  >EOF
  
  完成以上设置后,可以通过以下方式访问:
  
  1)打开浏览器
  
  2)输入以及
  
  3.基于域名的虚拟主机的访问
  
  1)vi /etc/http/conf/httpd.conf
  
  2)更改虚拟主机部分为:
  NameVirtualHost 192.168.0.1
  
  DocumentRoot /var/www/html/website1
  ServerName www1.example.com
  

  
  DocumentRoot /var/www/html/website2
  ServerName www2.example.com
  

  
  (注:以上设置中NameVirtualHost不可以省略)
  
  3)创建目录以及页面文件:
  #mkdir –p /var/www/html/website1
  #mkdir –p /var/www/html/website2
  #cd /var/www/html/website1
  #cat >index.html <  >website1
  >EOF
  #cd /var/www/html/website2
  #cat >index.html <  >website2
  >EOF
  
  4)完成以上设置后,可以通过以下方式访问:
  
  1)打开浏览器
  
  2)输入 以及
 
阅读(1479) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~