Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

3 Answers

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

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.