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:
- I changed the host names from
mysite1.localhost
tomysite.dev
because it sounds like the conflict is with.local
names – DID NOT WORK -
I updated the Hosts file to have separate
::1
addresses – DID NOT WORK:::1 <tab> mysite1.dev ::1 <tab> mysite2.dev
-
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.
Change MAMP cache to OPcache. It worked for me
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 inComment out Opcache:
Documentation ( yes it started in 5.5 ):
http://www.php.net/manual/en/intro.opcache.php
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:
Turning off Xdebug cut TTFB from 25 seconds to 2. Yeesh.
I had similar problems running php 5.5.3. After I changed back to
5.4.19
it worked.You can change the version in the
MAMP GUI
. You might have to rename your5.5.3
folder to5.5.X
for5.4.19
to show up in the GUI. Thephp
folders are placed at:Applications/MAMP/bin/php
For me, changing back to MAMPS standard port settings did the trick.
The solution that worked for me was to turn off Xdebug as @tammy-shipps mentioned. However since I have the vanilla MAMP version, I had to turn off Xdebug with the
php.ini
file found here:/{MAMP Directory}/bin/php/{PHP Version}/conf/php.ini
Then change
xdebug.remote_enable
from 1 to 0:xdebug.remote_enable=0
Unlike other proposed solutions, turning off cache or changing ports had no affect on the problem.
MAMP’s default ports are non-standard. When I switched to standard ports (80 for Apache & 443 for SSL), it sped up dramatically.
I’m not sure if this is what Paul Bakker did, or if he switched the other way.
I’m using MAMP Pro 4.2, PHP 7.1.6, Apache, OS X 10.11.6.
It was really hard, but I found a solution that it works in my environment:
SETTINGS left menu > Ports settings > Run servers as: > Change it to “Unix Users” option.
I was having same issue, I had added virtual host ending with
.local
which was causing 5 seconds delay in lookup.To fix this I updated host file.
And added my site with IPv6 address along with
::1
and127.0.0.1
.Setting xdebug.remote_host to to 127.0.0.1 instead of “localhost” solved this issue for me. This skips IPV6 resolution, which caused the delay.
Switching off remote_enable is not an option, because it kills debugging in PHPStorm:
I’m not sure about Mamp, however, I use
php -S 0.0.0.0:4444
to spin up a local server. Its response got very slow after moving to Mojave.I was able to fix it by updating
/etc/hosts
file withYou can get YourMacName.local by running in terminal:
Switch off the
PHP-Cache
as shown below screenshot.
Below in the screen shot you can see