Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mamp localhost resolving very slowly

When I make local changes to my PHP / WordPress website, the localhost does not seem to update for 20-30 minutes.

I'm on Mac OSX 10.8.4 and using MAMP Pro. I have two sites that I have created separate host entries for, let's call them mysite1.dev and mysite2.dev.

Here is my MAMP Server configuration:

Apache: 80
MySQL: 3306
SSL: 443

I saw this article ( How can I eliminate slow resolving/loading of localhost/virtualhost (a 2-3 second lag) on Mac OS X Lion? ) on the Bonjour conflicts and edited my /private/etc/hosts file with the suggestions in this article:

  1. I changed the host names from mysite1.localhost to mysite.dev because it sounds like the conflict is with .local names - DID NOT WORK

  2. I updated the Hosts file to have separate ::1 addresses - DID NOT WORK:

    ::1 <tab> mysite1.dev
    ::1 <tab> mysite2.dev
    
  3. I tried putting all of my host entries onto one line - also didn't work:

    127.0.0.1 localhost mysite1.dev mysite2.dev
    ::1 localhost
    fe80::1%lo0 localhost
    

It seems like MAMP Pro overwrites the hosts file any time I restart the server.

I would be SUPER grateful for any help you can offer.

like image 655
user2733720 Avatar asked Aug 30 '13 16:08

user2733720


2 Answers

I've been struggling with this issue ever since switching to SSL for my local environment (thanks, Salesforce API) and finally found a solution that worked for me:

Disable Xdebug

Turning off Xdebug cut TTFB from 25 seconds to 2. Yeesh.

like image 117
Tammy Shipps Avatar answered Sep 24 '22 13:09

Tammy Shipps


I had the same problem and found the solution on this post: MAMP time between seeing live changes

The instructions, which I followed:

The solution is uncommenting lines in the php.ini file, which can be found in

/{MAMP Directory}/bin/php/php5.5.3/conf/php.ini

Comment out Opcache:

[OPcache]
;zend_extension="/Applications/MAMP/bin/php/php5.5.3/lib/php/extensions/no-debug-non-zts-20121212/opcache.so"
;  opcache.memory_consumption=128
;  opcache.interned_strings_buffer=8
;  opcache.max_accelerated_files=4000
;  opcache.revalidate_freq=60
;  opcache.fast_shutdown=1
;  opcache.enable_cli=1

Documentation ( yes it started in 5.5 ):

http://www.php.net/manual/en/intro.opcache.php

like image 32
WaZzo Avatar answered Sep 24 '22 13:09

WaZzo