一个分享个人学习、开发经验的Blog,http://www.joyphper.net

使用apache服务器虚拟域名在本地测试网站

posted @ 2010-08-30 10:11 | 阅读:4911 | 评论:1 | 分类: Apache

 有时候在本地调试程序的时候总会出现一些目录一样的干拢,总会出现如下的地址http://127.0.0.1/test/,如果能把前面的127.0.0.1去了直接打入httpp://test/那岂快哉:

1、修改host文件

用记事本打开C:WINDOWSsystem32driversetchosts文件,你会看到如下的内容:

# Copyright (c) 1993-1999 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

127.0.0.1       localhost
在此内容后台加上127.0.0.1       test
现在http://test/所看的内容就与http://127.0.0.1所看到的内容就是一样的了

2、修改apache配置文件

打开httpd.conf文件

#NameVirtualHost *:80前面的#去了

再在最后加上

<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot E:/phproot/test
ServerName test
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

配置完毕,重启一下apache就OK了

TAG: apache , 本地解析 , 虚拟域名

共有1条评论 发表评论>>

Kameryn 发表于:2016-05-18 21:07
Wow! This can be one particular of the most beneficial blogs We2&1#87;ve ever arrive across on this subject. Basically Excellent. I am also a specialist in this topic therefore I can understand your hard work.
点击换一张验证码