2

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!

dcolumbus
  • 465
  • 1
  • 5
  • 10

3 Answers3

4

Change your ServerNames to example.dev or something other than .local. Forgot the technical explanation but basically, .local is used by Bonjour.

roflwaffle
  • 177
  • 6
  • I swear Apple used `.local` for mDNS and Bonjour *just* to make like difficult for companies with active directory and a `.local` TLD (which is almost all of them). – Mark Henderson Nov 25 '11 at 20:15
  • This was the fix! I'm not sure what changed, but myhost.local _used to_ work just fine. myhost.dev it is from now on. Thanks! – mpemburn Apr 16 '17 at 22:18
1

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.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
0

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.

emersonthis
  • 169
  • 1
  • 4
  • 11