利用Apache配置本地 自定义域名

第一步:配置 httpd.conf

    开启 虚拟主机 配置模块 去掉 " Include conf/extra/httpd-vhosts.conf "  前面的" # "

 Includeconf/extra/httpd-vhosts.conf

同时添加一个Listen 80

第二步:配置 httpd-vhosts.conf

    开始 将自定义的本地域名 与 web目录 关联  这里自定义了 

               www.lich.org  

               www.lich.com  

               www.lichina.com 

这三个本地域名 (当然这三个域名 是不能远程访问的 什么原因 你懂的!)

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName *
    DocumentRoot D:\web\apache2.2\Apache2\htdocs
</VirtualHost>

<VirtualHost *:80>
     ServerName www.royal.org
    DocumentRoot "D:\web\apache2.2\Apache2\htdocs\Royal"
	<Directory "D:\web\apache2.2\Apache2\htdocs\Royal">
		Options Indexes FollowSymLinks
		AllowOverride None
		Order allow,deny
		Allow from all
	</Directory>	
</VirtualHost>


<VirtualHost *:80>
    ServerName www.superapp.com
    DocumentRoot "D:\web\apache2.2\Apache2\htdocs\scApp7"
	<Directory "D:\web\apache2.2\Apache2\htdocs\scApp7">
		Options Indexes FollowSymLinks
		AllowOverride None
		Order allow,deny
		Allow from all
	</Directory>	
</VirtualHost>


<VirtualHost *:80>
    ServerName www.api.com
    DocumentRoot "D:\web\apache2.2\Apache2\htdocs\taobaoApi"
	<Directory "D:\web\apache2.2\Apache2\htdocs\taobaoApi">
		Options Indexes FollowSymLinks
		AllowOverride None
		Order allow,deny
		Allow from all
	</Directory>	
</VirtualHost>

  

第三步: 配置windows hosts文件

    打开 C:\WINDOWS\system32\drivers\etc\hosts 文件 

   (hosts文件其实 就是 internet 的雏形 最早的internet 是 ARPA 用于内部的 主机的域名解析)

127.0.0.1 localhost
127.0.0.1 www.lich.org 
127.0.0.1 www.lich.com 
127.0.0.1 www.lichina.com

  第四步:没哟了! 在浏览器上 输入 www.lichina.com  www.lich.com  www.lich.org  就会访问不同的本地web目录

posted @ 2016-11-24 13:52  Lichina  阅读(961)  评论(0编辑  收藏  举报