、打开系统盘,默认是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. [SOJ] 导游

    Description Mr. G. 在孟加拉国的一家旅游公司工作.他当前的任务是带一些游客去一些遥远的城市.和所有国家一样,一些城市之间有双向道路.每对相邻城市之间都有一条公交路线,每条路线都规定了 ...

  2. 洛谷-均分纸牌-NOIP2002提高组复赛

    题目描述 Description 有 N 堆纸牌,编号分别为 1,2,…, N.每堆上有若干张,但纸牌总数必为 N 的倍数.可以在任一堆上取若于张纸牌,然后移动. 移牌规则为:在编号为 1 堆上取的纸 ...

  3. DUIlib使用Fastreport--报表简单使用

    fastreport是一个简单优秀的报表,fastreport更多是和delphi联合使用预览和打印数据的.我在开始使用duilib做项目时,打印和数据预览都是自己绘制的,这样不仅绘制麻烦费事费事,而 ...

  4. layer1.8UI

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  5. python 基础学习1

    1.注释 与shell一样,python也是以#开始为注释语句 2.运算符 + - * / // ** python中有2种除法:单斜杠是普通除法,双斜杠是浮点数除法(结果四舍五入) < < ...

  6. 在cmd中设置字体

    1.首先在cmd中输入chcp 65001 回车(通过 chcp命令改变代码页,UTF-8的代码页为65001) 2.右击命令提示符的标题栏点击属性. 3.在属性中选择字体后点击确认即可.

  7. 去除右键的opendgl

    Windows Registry Editor Version 5.00[-HKEY_CLASSES_ROOT\Unknown\shell\opendlg][-HKEY_CLASSES_ROOT\Un ...

  8. hdu1013

    #include<stdio.h> #include<string.h> int main() { char num[1000]; int len,sum,i; while(s ...

  9. noip2013Day2T3-华容道【一个蒟蒻的详细题解】

    描述 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面,华容道是否根本就无法完成,如果能完成,最少需要多少时间. 小 B 玩的华容道与经典的 ...

  10. scroll、client和offset的区别

    scroll.client和offset的区别:http://www.cnblogs.com/pcd12321/p/4448420.html