apache搭建虚拟主机

 apache搭建虚拟主机有两方法。

  第一步完成apache虚拟目录配置;

  第二步到httd.conf里面找到

     # Virtual hosts 虚拟主机

Include conf/extra/httpd-vhosts.conf 

找到后去掉#注释.

 第三步打开 conf/extra/httpd-vhosts.conf 文件

 接下来有两种配置方法。

 1-添加下面代码

 

  
  
  
  
  1. <VirtualHost *:80> 
  2.     ServerAdmin [email protected] 
  3.     DocumentRoot "D:/myblog"  //这里的d就是你虚拟目录的位置了 
  4.     ServerName www.lengai.com //这里是你要映射的域名
  5.     ErrorLog "logs/demo.neoease.com-error.log" 
  6.     CustomLog "logs/demo.neoease.com-access.log" common 
  7. </VirtualHost> 

 重启apache就ok了.

2-添加下面代码

 

  
  
  
  
  1. <VirtualHost 127.0.0.1:80> //这里的ip地址要注意。这样配置其他电脑是连接不到的。必须改为网卡地址。
  2.    DocumentRoot "D:/myblog" //虚拟目录地址 
  3.    DirectoryIndex index.html index.htm index.php   
  4.    <Directory /> //权限 
  5.    Options FollowSymLinks 
  6.    Allowoverride None 
  7.    order Allow,deny 
  8.    Allow from all 
  9.    </Directory> 
  10. </VirtualHost> 

重启apache可以了

个人更喜欢第一种方法。

 

 

  

你可能感兴趣的:(虚拟主机,apachea,apache搭建虚拟主机,搭建虚拟主机)