利用Apache配置本地域名(wamp 集成环境下 )

来源:互联网 发布:hadoop大数据开发项目 编辑:程序博客网 时间:2024/05/04 13:12

第一步:配置 D:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf

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

                # Virtual hosts Includeconf/extra/httpd-vhosts.conf

第二步:配置D:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf

    定义本地域名所指向的目录,以及设置的域名,在本地环境下

<VirtualHost *:80>    ServerAdmin webmaster@dummy-host2.example.com    DocumentRoot "D:\wamp\www\tp\shop"                                        //域名指向目录    ServerName shop.com                                                       //自定义的本地域名    ErrorLog "logs/dummy-host2.example.com-error.log"    CustomLog "logs/dummy-host2.example.com-access.log" common</VirtualHost><VirtualHost *:80>    ServerAdmin webmaster@dummy-host2.example.com    DocumentRoot "D:\wamp\www\ecshop"                                          //域名指向目录    ServerName ecshop.yan                                                      //自定义的本地域名    ErrorLog "logs/dummy-host2.example.com-error.log"    CustomLog "logs/dummy-host2.example.com-access.log" common</VirtualHost><VirtualHost *:80>    ServerAdmin webmaster@dummy-host2.example.com    DocumentRoot "D:\wamp\www\phpcms"                                          //域名指向目录    ServerName phpcms.yan                                                      //自定义的本地域名    ErrorLog "logs/dummy-host2.example.com-error.log"    CustomLog "logs/dummy-host2.example.com-access.log" common</VirtualHost>

第三步: 配置windows hosts文件

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

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

127.0.0.1       shop.com127.0.0.1       ecshop.yan127.0.0.1       phpcms.yan

这样,直接在浏览器地址栏输入shop.com、ecshop.yan、phpcms.yan即可分别打开相对应的项目或页面。。

0 0