Handle Slow PHP cli with IMAP extension on macOS
About two weeks ago, I installed a PHP project that required the IMAP extension. I installed it via MacPorts, and everything seemed okay. However, after that, I experienced very slow execution when running PHP via the CLI.
I am using macOS Monterey, which was released in 2021. It turns out that the issue has existed since 2016 on macOS Sierra. This was discussed on Stack Overflow in 2017:
The issue has already been reported to php-src:
I couldn’t reproduce the issue on Linux Ubuntu 22.04.
Following the Stack Overflow answer mentioned above, I tried to add my hostname to the /etc/hosts
file. First, I obtained the hostname:
➜ ~ hostname Abduls-Mac-mini.local
My original /etc/hosts
file had the following entries:
127.0.0.1 localhost ::1 localhost
Then, I added the hostname to the third column on each row:
127.0.0.1 localhost Abduls-Mac-mini.local ::1 localhost Abduls-Mac-mini.local
After that, the issue was resolved, and it became fast again. That’s it! 😉
References:
leave a comment