如何在Mac OS X Lion上消除localhost / virtualhost慢速解析/加载(2-3秒滞后)? [英] How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion?
问题描述
自从在Mac OS X Lion(2012年1月份购买的全新Macbook Air)中设置开发环境以来,我注意到第一次解析到虚拟主机的速度非常慢(约3秒钟),但之后是快速的只要我继续定期加载它。
Since setting up my development environments on Mac OS X Lion (brand new macbook air purchased in January 2012), I have noticed that resolving to a virtual host is very slow (around 3 seconds) the first time but after that is fast as long as I continue loading it regularly.
如果我把它保持不变几分钟,然后重新加载,第一次重新加载就是(再次)痛苦的慢;好像有东西被缓存。
If I leave it untouched for a couple of minutes and then reload again, the first reload is (again) painfully slow; seems like something is being cached.
如下所示,我没有使用.local TLD。
As can be seen below I am not using the .local TLD.
我的设置:Apache 2 - MySQL - PHP安装并启用 - 添加了几个虚拟主机,其中一个为localhost创建了
My setup: Apache 2 - MySQL - PHP installed and enabled - added a couple of virtual hosts one of which I created for localhost
我的/ etc / hosts:
My /etc/hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 myproject.dev
::1 myproject.dev
fe80::1%lo0 myproject.dev
我的虚拟主机设置在username.conf中:
My virtual host set-up in username.conf:
NameVirtualHost *:80
<Directory "/Users/myusername/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/myusername/Dropbox/dev_envs/
</VirtualHost>
<VirtualHost *:80>
ServerName myproject.dev
DocumentRoot /Users/myusername/Dropbox/dev_envs/myprojectname
</VirtualHost>
推荐答案
我有完全相同的问题,疯狂!
I had the exact same problem and it was driving me crazy!
将本地主机的所有主机文件输入一行如下:
Put all your hosts file entries for localhost into one line like so:
127.0.0.1 localhost myproject.dev myotherproject.dev
::1 localhost
fe80::1%lo0 localhost
像我一样的魅力。似乎像狮子的一个bug。
Worked like a charm for me. Seems like a bug in Lion.
这篇关于如何在Mac OS X Lion上消除localhost / virtualhost慢速解析/加载(2-3秒滞后)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!