Ive just started to encounter a problem with MAMP PHP running extremely slowly. Ive reinstalled MAMP and still having issues.
As a comparison (I thought maybe my local development OS X machine may have been having issues) i tried the following in terminal, and disabled php.ini with -n
/usr/bin/php --version -n
This returns with an output immediately.
/Applications/MAMP/bin/php/php5.5.14/bin/php --version -n
This returns an output approx 3-5 seconds later.
I have tried running numerous other commands and scripts. All seem to have a delay of 3-5 seconds with MAMP PHP.
I have tried other MAMP PHP versions, and they still have the same issues.
I can't think of anything that has changed recently on my machine to cause this slow down (e..g no php.ini changes, no OS X updates)
I really have no idea whats causing this problem, or even how to investigate things further. Help greatly appreciated.
UPDATE
Strangely, the problem only seems to be when running MAMP PHP in command line. When loading a website using MAMP, there is no slow down. Even more confusing...
Solved. For some reason -n
was not removing the .ini files. Deleting the .ini file altogether solved the issue.
Some googling lead me to the extension causing the issue. I commented out the following line in my .ini file
; extension=imap.so
As indicated by the other replies, the slow-down is caused by the imap.so extension.
Looking deeper into this though, it appears that the reason why is that it's trying perform a DNS lookup for the local machine's hostname.
Adding your hostname to your /etc/hosts file should fix it:
me@mbp ~> hostname
mbp.local
cat /etc/hosts
...
127.0.0.1 mbp.local
::1 mbp.local
...
Before:
me@mbp ~> time php -v
PHP 7.0.12 (cli) (built: Oct 24 2016 18:49:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
**5.04 real** 0.01 user 0.01 sys
After:
me@mbp ~> time php -v
PHP 7.0.12 (cli) (built: Oct 24 2016 18:49:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
**0.03 real** 0.01 user 0.00 sys
I discovered this by capturing the network traffic using Wireshark.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With