、打开系统盘,默认是C:\Windows\System32\drivers\etc,如果系统盘是D盘就打开D:\Windows\System32\drivers\etc:

、用记事本打开hosts:

、打开之后默认如下,不太一样也不要在意。因为这个有可能不相同的。

、 127.0.0.1为本地ip 可以为其他ip设置名称,本地也可以添加多个

# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost
127.0.0.1       www.test.com
127.0.0.1       www.fh.com
127.0.0.1       www.test_my.com

 
设置之后需要到apache配置文件中配置文件
1、

首先修改C:\Windows\System32\drivers\etc目录下的 hosts 文件,用记事本打开,加入:

# Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost
127.0.0.1       www.test.com
127.0.0.1       www.fh.com
127.0.0.1       www.test_my.com

//127.0.0.1 www.a.com127.0.0.1 www.b.com记得去掉前面的

 
2、

打开xampp\apache\conf\httpd.conf文件,搜索 “Include conf/extra/httpd-vhosts.conf”,确保前面没有 # 注释符,也就是确保引入了 vhosts 虚拟主机配置文件。效果如下:

# Virtual hosts

Include "conf/extra/httpd-vhosts.conf"

开启了httpd-vhosts.conf,默认a的httpd.conf默认配置失效(确保 httpd-vhosts.conf 文件里也开启了虚拟主机配置,见第3条),访问此IP的域名将全部指向 vhosts.conf 中的第一个虚拟主机。

3、

在虚拟主机设置文件xampp\apache\conf\extra \httpd-vhosts.conf里设置:取消 NameVirtualHost *:80 前面的 ##,这样就启用了 vhosts.conf ,默认的httpd.conf默认配置失效。虚拟主机配置将只设置在httpd-vhosts.conf里。localhost 的目录默认配置记得也按此设置。

<VirtualHost *:80>
    ServerAdmin fh@fh.com
    DocumentRoot "D:/feihu/xampp/htdocs/mylaravel/public"
    ServerName www.fh.com
    ErrorLog "logs/fh.com-error.log"
    CustomLog "logs/fh.com-access.log" common
</VirtualHost>

#

# Use name-based virtual hosting.

#

NameVirtualHost *:80

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for all requests that do not

# match a ServerName or ServerAlias in any block.

#

ServerAdmin postmaster@dummy-host.localhost

DocumentRoot "I:/xampp/htdocs/"

ServerName localhost

ServerAlias localhost

ErrorLog "logs/dummy-host.localhost-error.log"

CustomLog "logs/dummy-host.localhost-access.log" combined

ServerAdmin postmaster@dummy-host1.localhost

DocumentRoot "I:/xampp/htdocs/a"

ServerName www.a.com

ServerAlias www.a.com

ErrorLog "logs/dummy-host1.localhost-error.log"

CustomLog "logs/dummy-host1.localhost-access.log" combined

ServerAdmin postmaster@dummy-host2.localhost

DocumentRoot "I:/xampp/htdocs/b/"

ServerName www.b.com

ServerAlias www.b.com

ErrorLog "logs/dummy-host2.localhost-error.log"

CustomLog "logs/dummy-host2.localhost-access.log" combined

//至此,XAMPP 的虚拟主机设置完毕,现在 访问 localhost 还是原来的 XAMPP 的帮助指南,访问 www.a.com 将指向到绑定的 a 目录,访问 www.b.com 将指向到绑定的 b 目录。

 
 访问www.fh.com将访问刚才设置的自定义文件夹

搭建localhost的目录环境的更多相关文章

  1. 史上最全Windows版本搭建安装React Native环境配置

    史上最全Windows版本搭建安装React Native环境配置 配置过React Native 环境的都知道,在Windows React Native环境配置有很多坑要跳,为了帮助新手快速无误的 ...

  2. 阿里云上安装mysql步骤/ 阿里云ECS搭建Java+mysql+tomcat环境

    使用阿里云ECS挺长一段时间了.这两天碰巧朋友小白让我一步一步教他在ECS上搭建Java+mysql+tomcat环境,所以把在这里把步骤在这简单整理了一下,以便需要的人查阅. 我购买的阿里云服务器系 ...

  3. 史上最详细Windows版本搭建安装React Native环境配置 转载,比官网的靠谱亲测可用

    史上最详细Windows版本搭建安装React Native环境配置   2016/01/29 |  React Native技术文章 |  Sky丶清|  95条评论 |  33530 views ...

  4. 搭建FTP+PAM+MySQL环境

    搭建FTP+PAM+MySQL环境 1 搭建环境: CentOS6.5或CentOS6.7 [root@vhost3 ~]# uname -a Linux vhost3 -.el6.x86_64 # ...

  5. 手把手教你用webpack3搭建react项目(开发环境和生产环境)(一)

    开发环境和生产环境整个配置源码在github上,源码地址:github-webpack-react 如果觉得有帮助,点个Star谢谢!! (一)是开发环境,(二)是生产环境. 一.首先创建packag ...

  6. 15分钟在笔记本上搭建 Kubernetes + Istio开发环境

    11月13~15日,KubeCon 上海大会召开,云原生是这个秋天最火热的技术.很多同学来问如何上手 Kubernetes和Istio 服务网格开发.本文将帮助你利用Docker CE桌面版,15分钟 ...

  7. 使用Vagrant搭建本地python开发环境

    使用Vagrant搭建本地python开发环境 关于vagrant:Vagrant是一个基于Ruby的工具,用于创建和部署虚拟化开发环境,它使用Oracle的开源VirtualBox虚拟化系统也可以使 ...

  8. 使用intellij idea搭建spring-springmvc-mybatis整合框架环境

    使用intellij idea搭建spring-springmvc-mybatis整合框架环境   1.打开idea,创建maven项目,File-New-Project 2.选择Maven,勾选Cr ...

  9. Hadoop2.7.3+HBase1.2.5+ZooKeeper3.4.6搭建分布式集群环境

    Hadoop2.7.3+HBase1.2.5+ZooKeeper3.4.6搭建分布式集群环境 一.环境说明 个人理解:zookeeper可以独立搭建集群,hbase本身不能独立搭建集群需要和hadoo ...

随机推荐

  1. IntentService和Service的区别

    整个看下来是一个Service+Thread+handle的结合体, Service:比Activity的被kill的级别低 Thread:不阻塞UI线程 Handle:队列式的消息循环 那这个玩意的 ...

  2. delphi倒计时按钮写法

    procedure TForm1.FormActivate(Sender: TObject); var i: Integer; begin btn8.Enabled:=False; do begin ...

  3. lvs 会话保持(转发)

    lvs & keepalived的tcp 长连接的问题解决办法 虽然应用keepalived搞定了后端服务负载均衡和高可用性问题,但是在具体应用的时候,还是要注意很多问题.很多应用都用tcp或 ...

  4. Code Sign error: No code signing identities found: No valid signing identities

    Code Sign error: No code signing identities found: No valid signing identities 解决办法:如果证书可获取,最简办法就是把所 ...

  5. inception cenOS 安装

    inception手册http://mysql-inception.github.io/inception-document/install/ 执行命令sh inception_build.sh,ce ...

  6. WPF之DatePicker使其只能选择日期,不能输入日期

    <DatePicker.Resources>  <Style TargetType="DatePickerTextBox">           <S ...

  7. How to use php serialize() and unserialize()

    A PHP array or object or other complex data structure cannot be transported or stored or otherwise u ...

  8. pre标签

    $(" .pop-info").html("<PRE>"+data.info+"<PRE>"): 数据库里的换行存的 ...

  9. win10锁屏壁纸路径

    C:\Users\ShanYu\AppData\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalS ...

  10. 配置Windows为NTP服务器

    建议使用 ntpd for windows,这是一个ntp的windows版,操作和linux相似 下载:https://www.meinbergglobal.com/english/sw/ntp.h ...