Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstnorris's avatar

PHP from the terminal running very slow on new mac!

I have restored my Mac back to factory installation of Mac OS X 10.10 Yosemite and have put just a few applications on:

PhpStorm, Sublime, Xcode, SequelPro, iTerm2, VirtualBox etc

I have installed PHP from http://php-osx.liip.ch as I am using Homestead for actual project development but I like to run things locally for quickness.

The problem I am having is that php has a 5 second delay with everything I run.

Running php -v yields

PHP 5.6.6 (cli) (built: Feb 20 2015 22:47:58)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Running which php yields (showing that I am using the PHP-OSX.LIIP version from the link above.

/usr/local/php5/bin/php

My /etc/hosts file is now very lean compared to what it was before I restored my Mac.

##
# 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

# Local server details
192.168.0.4     server

# Homestead Development
192.168.10.10   my-project.dev

When I run time php index.php on an extremely simple page I can confirm that it takes over 5 seconds to run. (I'm following @JeffreyWay's tutorial on the Template design pattern)

string(21) "laying down the bread"
string(16) "add some lettuce"
string(15) "add some turkey"
string(19) "add oil and vinegar"

real    0m5.046s
user    0m0.027s
sys 0m0.013s

When I run it again just to check...

string(21) "laying down the bread"
string(16) "add some lettuce"
string(15) "add some turkey"
string(19) "add oil and vinegar"

real    0m3.690s
user    0m0.027s
sys 0m0.017s

Does anyone have any idea why it would be doing this?

0 likes
15 replies
Chris Magnussen's avatar

Try adding your hostname in the /etc/hosts file

::1         localhost YourMac.local
127.0.0.1   localhost YourMac.local
5 likes
mstnorris's avatar

Unfortunately that didn't work.

I still have my previous hosts file and that didn't include my hostname like that and it worked absolutely fine.

Someone has replied to a GitHub issue for the PHP-OSX.LIIP project and supposedly it is something to do with the IMAP extension but I am not sure how to disable it.

Chris Magnussen's avatar

I don't have any experience with php-osx, but maybe check /usr/local/php5/php.d/99-liip-developer.ini (php.ini) and see if it's loaded there. Comment it out if it is.

bashy's avatar

You can check where it's being loaded from, maybe with this

php -i | grep "imap"

// Example, this shows ext-mcrypt.ini being loaded
php -i | grep "mcrypt"
mstnorris's avatar

Thank you both,

@bashy I have run that and I get this

php -i | grep "imap"
Configure Command =>  './configure'  '--prefix=/usr/local/php5' '--with-apxs2=/usr/sbin/apxs' '--with-config-file-scan-dir=/usr/local/php5/php.d' '--with-libxml-dir=shared,/usr' '--with-openssl=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-gd' '--with-ldap' '--with-xmlrpc' '--enable-exif' '--enable-soap' '--enable-wddx' '--enable-ftp' '--enable-sockets' '--with-bz2=/usr' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-bcmath' '--enable-calendar' '--with-mhash' '--enable-fpm' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-dtrace' '--enable-opcache' '--with-icu-dir=/usr/local/php5' '--with-mssql=shared,/usr/local/php5' '--with-pdo-dblib=shared,/usr/local/php5' '--with-xsl=shared,/usr/local/php5' '--with-imap=shared,../imap-2007f' '--with-kerberos=/usr' '--with-imap-ssl=/usr' '--with-gettext=/usr/local/php5' '--with-curl=shared,/usr/local/php5' '--with-png-dir=/usr/local/php5' '--with-jpeg-dir=/usr/local/php5' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/php5' '--with-pgsql=shared,/usr/local/php5' '--with-pdo-pgsql=shared,/usr/local/php5' '--with-mcrypt=shared,/usr/local/php5' '--with-tidy=/usr/local/php5' '--with-gmp=shared,/usr/local/php5' '--with-readline=shared,/usr/local/php5' 'CC=cc '-L/usr/local/php5/lib' '-I/usr/local/php5/include' '-I/usr/include/libxml2' '-I/usr/local/php5/include/tidy' '-DENTROPY_CH_RELEASE=1'' 'CFLAGS=-g '-O' '-mmacosx-version-min=10.10' '-I/usr/local/php5/include' '-arch' '-no-cpp-precomp' '-DENTROPY_CH_ARCHS='''i386/x86_64'''' '-DENTROPY_CH_RELEASE=1'' 'LDFLAGS=-L/usr/local/php5/lib '-arch' 'CXXFLAGS=-arch
/usr/local/php5/php.d/50-extension-imap.ini,
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
imap

What should I do now, that doesn't mean anything to me.

bashy's avatar

So all your extensions are loaded from /usr/local/php5/php.d

You can disable them in there (delete or comment out inside file).

Chris Magnussen's avatar
Level 3

Have a look in /usr/local/php5/php.d/50-extension-imap.ini and comment out the extension=..imap.so line.

9 likes
slaattene's avatar

Fixed it for me aswell. Thank you Chris Magnussen!

1 like
wh33ler's avatar

adding hostname.local to my /etc/hosts fixed it for me as well. Thanks for the help

f3l1x's avatar

Hi!

I confirm that /etc/hosts fixed that issue.

$ php -v
PHP 7.2.0beta1 (cli) (built: Jul 24 2017 10:33:19) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0-dev, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.0beta1, Copyright (c) 1999-2017, by Zend Technologies

Please be aware you have to use your hostname, not your username, in /etc/hosts.

It takes me an hour of my life. ;-)

Bonbonzone's avatar

Adding hostname to hosts file usually works for me but I just moved offices and came up against the issue again. Switching to using Google's DNS worked (8.8.8.8 & 8.8.4.4)

YazanStash's avatar

Editing hosts file worked for me 🤷🏼‍♂️

Please or to participate in this conversation.