Apache的虚拟主机查找缓慢

Apache的虚拟主机查找缓慢

本文介绍了Apache的虚拟主机查找缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最终如何正确的httpd.conf配置我的虚拟主机needings。这是httpd.conf文件的相关部分。

I finally managed how to configure properly httpd.conf for my virtualhost needings. This is the relevant part of httpd.conf file

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /Applications/XAMPP/htdocs/
</VirtualHost>

<VirtualHost *:80>
  ServerName test.local
  DocumentRoot /Applications/XAMPP/htdocs/test/
</VirtualHost>

<VirtualHost *:80>
  ServerName work.local
  DocumentRoot /Applications/XAMPP/htdocs/work/
</VirtualHost>

当我访问任何本地主机(即)一切都非常快。
每当我访问test.local或work.local(或其他人我配置),它花费在查找10-15秒。下面的请求被正确处理,这是非常快,但一分钟左右后不活动的,它必须再次查找。

When I access anything on localhost (i.e. http://localhost/phpmyadmin) everything is very fast.Whenever I access test.local or work.local (or others I configured) it spends 10-15 seconds on lookup. The following requests are handled correctly and it's very fast but after a minute or so of inactivity, it has to lookup again.

这是我的/ etc / hosts文件

This is my /etc/hosts file

127.0.0.1       localhost
255.255.255.255 broadcasthost
#::1             localhost
fe80::1%lo0     localhost

# Virtualhosts
127.0.0.1       test.local     work.local    yii.local

我怎么能解决这个恼人的问题?

How could I fix this annoying issue?

推荐答案

添加虚拟主机的第一行:

Add your virtual hosts to the first line:

127.0.0.1       localhost test.local work.local yii.local

和删除最后一行。

这是应该做的伎俩。您的虚拟主机现在是本地主机的别名。这不是在多行相同的IP地址是一个好主意。这只是混淆了DNS缓存。

That should do the trick. Your vhosts are now an alias for localhost. It's not a good idea to have the same IP-address in multiple lines. This just confuses the DNS-cache.

这篇关于Apache的虚拟主机查找缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 11:52