自从我开始使用MAMP的Vhosts,页面请求一直很慢。 处理页面请求需要3到5秒钟或更长时间。 我想知道是否我的hosts或vhosts文件的设置方式:
主机:
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 mysite.local www.mysite.local 127.0.0.1 anothersite.local www.anothersite.local
的httpd-vhosts.conf
NameVirtualHost *:80 <VirtualHost *:80> ServerName mysite.local ServerAlias www.mysite.local DocumentRoot /Users/username/Sites/mysite.local/ <Directory /Users/username/Sites/mysite.local/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost> <VirtualHost *:80> ServerName anothersite.local ServerAlias www.anothersite.local DocumentRoot /Users/username/Sites/anothersite.local/ <Directory /Users/username/Sites/anothersite.local/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> </VirtualHost>
非常感谢您的帮助!
将您的ServerName更改为example.dev或.local以外的内容。 基本上忘了技术说明,Bonjour使用.local 。
/etc/hosts/中的东西的hostsparsing过程非常非常快,即使在那里有数百个主机声明。 名称服务caching守护进程也将这些查找保存在内存中,所以它们应该更快。
问题很可能在别的地方。
我正在解决这个相同的问题。 我还没有完全弄明白,但我注意到,当我编辑我的/ etc / hosts文件时,我必须input我的pipe理员密码(我认为这是OSX启用sudo命令的方式)。 在接下来的几分钟里我的本地testing网站很快。 最后他们又回到了难以忍受的速度。 我可以通过向我的/ etc / hosts添加一个空行来修复它(因为它使我再次input密码),但一次只能持续几分钟。
我认为这个信息对解决这个问题很重要,但我不知道如何。 也许别人可以帮助理解它。