Ever since I started using Vhosts with MAMP, page requests have been quite slow. It takes 3 to 5 seconds or more to process a page request. I'm wondering if it's the way my hosts
or vhosts
files are setup:
hosts:
##
# 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>
Your help is greatly appreciated!
Change your
ServerName
s toexample.dev
or something other than.local
. Forgot the technical explanation but basically,.local
is used by Bonjour.The
hosts
resolution process for things in/etc/hosts/
is very, very fast, even if there are hundreds of host declarations in there. The name-service cache daemon keeps such lookups in memory as well, so they should be even faster.The problem is most likely somewhere else.
I'm troubleshooting this very same issue. I haven't figured it out entirely, but I have noticed that when I edit my /etc/hosts file, I have to enter my admin password (which I think is OSX's way of enabling sudo commands). For the next couple minutes my local testing sites are snappy. Then eventually they go back to being unbearably slow. I can fix it by adding a blank line to my /etc/hosts (because it makes me enter the password again) but it only lasts for a few minutes at a time.
I think this information is important to solving this issue, but I'm not sure how. Maybe someone else can help make sense of it.