Apache配置完虚拟主机后,使用Chrome访问localhost还是默认目录htdocs
Chrome 解析DNS出错,这个错误比较罕见,甚至说有点奇特。今天在使用Apache配置虚拟主机时,出现了一个非常奇怪的现象。我按照配置的步骤配置虚拟主机,如下
配置虚拟主机的步骤如下:
1. 启用 httpd-vhosts.conf
在 httpd.conf 文件中
# Virtual hosts ,虚拟主机
Include conf/extra/httpd-vhosts.conf
2. 在httpd-vhosts.conf文件中做配置
#配置我们自己的虚拟主机
<VirtualHost 127.0.0.1:80>
DocumentRoot "d:/myblog"
#这里配置欢迎首页面
DirectoryIndex index.html index.htm index.php
<Directory />
Options FollowSymLinks
#不许可别人修改我们的页面
AllowOverride None
#设置访问权限
Order allow,deny
Allow from all
//由于版本更新,所以这个语句不能再使用,Apache2.4需要使用Require all granted
</Directory>
</VirtualHost>
3.修改hosts 文件
.127.0.0.1 localhost
但是很遗憾的是,我调试的浏览器是Chrome,这就使得我刚开始解决问题时就出现错误的方向,我刚开始认为是自己的配置错误,所以一直在尝试,但是最后都没有发现问题,Chrome浏览器停留在这个页面。(这个页面就是Apache的默认页面,而不是虚拟主机中的页面)

后来,我觉得会不会是hosts文件出错呢?所以我尝试使用IP:http://127.0.0.1/访问,让我惊讶的是,这时候访问成功了。


|
down voteaccepted
|
方法一:1Clear up the Chrome's DNS cache by typing this in the Chrome browser
Screenshot -> Flushing Chrome DNS cache
方法二:Another solution could be to ditch the .localhost /.dev at the end of your local virtual host domain This has to do with some new changes by google. ".dev" and ".local" comes under google's TLD (In the corner of the internet where people care about DNS, there is a bit of an uproar at Google's application for over a hundred new top-level domains, including .dev etc) Use a domain name you own. Possibly using the full name like "localhost.dev.$yourdomain" could help here on the setup. |
Apache配置完虚拟主机后,使用Chrome访问localhost还是默认目录htdocs的更多相关文章
- Apache配置虚拟主机后,不能访问localhost的问题
今天想试用一下php7,但是发现php7只支持Apache2.4版本,而我电脑上的Apache是2.2版本,为了想尝鲜,就必须去下载新的Apache2.4 php7和apache2.4安装整合以后,l ...
- Linux配置虚拟主机后,只能访问到主页怎么办?
Linux配置虚拟主机后,只能访问到主页怎么办? 今天配置了lamp后,添加了一个虚拟主机,配置http.conf后,增加虚拟主机,测试访问发现只有域名下能访问,ljt.com但是域名下所有的都访问不 ...
- PHP中级篇 Apache配置httpd-vhosts虚拟主机总结及注意事项[OK]
经常使用Apache虚拟主机进行开发和测试,但每次需要配置虚拟主机时都习惯性的ctrl+c和ctrl+v,这次由于重装系统,需要配置一个新的PHP开发环境虚拟主机,于是总结一下Apaceh配置http ...
- PHP中级篇 Apache配置httpd-vhosts虚拟主机总结及注意事项
经常使用Apache虚拟主机进行开发和测试,但每次需要配置虚拟主机时都习惯性的ctrl+c和ctrl+v,这次由于重装系统,需要配置一个新的PHP开发环境虚拟主机,于是总结一下Apaceh配置http ...
- wamp配置apache虚拟主机支持多域名访问localhost
1.背景: 在进行网站开发的时候,通常需要以http://localhost或者127.0.0.1等地址来访问本地环境的网站.不过随着开发项目的增多,需要每次先访问localhost然后再选项目,显得 ...
- centos5.5用phpstudy一键安装配置虚拟主机后,yum配置代理服务器squid
最近因为工作需要,开发站点需要在lamp环境下跑网站,于是在win7上跑虚拟机装了一个centos5.5的linux 并用集成环境配置了一个lamp环境,这里用的是phpstudy的一键安装包,并配置 ...
- apache配置虚拟主机后,启动速度慢
apache配置虚拟主机后,启动速度慢且提示“the requested operation has failed” 可以通过在cmd下启动,来查找问题(命令中的“apache2.2”,是服务名,根据 ...
- Apache配置虚拟主机后让其他电脑访问
关于Apache配置虚拟主机后在局域网中让其他电脑访问 #test1# NameVirtualHost *:80 ServerName www.t1.com Document ...
- 关于Apache配置虚拟主机后在局域网中让其他电脑访问
#-----------adxssp------------# NameVirtualHost *:80 <VirtualHost *:80> ServerName www.b.com D ...
随机推荐
- poj 1704 Georgia and Bob(阶梯博弈)
Georgia and Bob Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8656 Accepted: 2751 D ...
- 4G来临 IT业转型之路当在不远
摘 要:4G商用未启,品牌营销争夺已经展开.目前,除了中国移动推出全新4G品牌“andM”之外,中国电信和中国联通均选择继续沿用3G的品牌. 4G商用未启,品牌营销争夺已经展开.12月10日,中国电信 ...
- thinkphp 重定向redirect
/** * URL重定向 * @param string $url 重定向的URL地址 * @param integer $time 重定向的等待时间(秒) * @param string $msg ...
- 基于JAX-WS的Web Service服务端/客户端 ;JAX-WS + Spring 开发webservice
一.基于JAX-WS的Web Service服务端/客户端 下面描述的是在main函数中使用JAX-WS的Web Service的方法,不是在web工程里访问,在web工程里访问,参加第二节. JAX ...
- 通过mybatis读取数据库数据并提供rest接口访问
1 mysql 创建数据库脚本 -- phpMyAdmin SQL Dump -- version 4.2.11 -- http://www.phpmyadmin.net -- -- Host: lo ...
- nodejs 简单对mongodb 操作
路由到了 index.js /* * GET home page. 控制器 */ exports.index = function(req, res){ // res.render('index', ...
- 内核代码架构图 :systemtap函数选择点
- 使用AVCaptureSession显示相机预览
#import <UIKit/UIKit.h> #import <AVFoundation/AVFoundation.h> @interface ViewController ...
- css考核点整理(九)-有几种文字替换方式,之间的优缺点
有几种文字替换方式,之间的优缺点
- 【转载】Shared Configuration
Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...