1. 1.编辑apache配置文件 
  2. vim /etc/httpd/conf/httpd.conf 
  3. #在最后面添加如下内容 
  4. Listen 81 
  5. Listen 82 
  6. <VirtualHost *:81> 
  7.     ServerAdmin http://192.168.1.39 
  8.     DocumentRoot /data/vhost1 
  9.     ErrorLog logs/vhost1_error_log 
  10.     CustomLog logs/vhost1_access_log common 
  11. </VirtualHost> 
  12.  
  13.  
  14. <VirtualHost *:82> 
  15.     ServerAdmin http://192.168.1.39 
  16.     DocumentRoot /data/vhost2 
  17.     ErrorLog logs/vhost1_error_log 
  18.     CustomLog logs/vhost1_access_log common 
  19. </VirtualHost> 
  20.  
  21. 2.创建目录 
  22. mkdir /data/vhost1 
  23. mkdir /data/vhost2 
  24.  
  25. 3.添加测试文件 
  26. vim /data/vhost1/index.html 
  27. #添加如下内容: 
  28. vhost1 
  29.  
  30. vim /dta/vhost2/index.html 
  31. #添加如下内容: 
  32. vhost2 
  33.  
  34. 4 重启apache 服务器 
  35. /etc.init.d/httpd  restart 
  36.  
  37. 5.测试 
  38. 在浏览器里面分别输入 http://ip:81  和   http://ip:82 
  39. 显示结果应该是: vhost1   和   vhost2