Hi Dear reader!

You may be wondering why I am writing yet another article about xDebug installation on Mac OSX, but in fact, I am writing this more because of myself as I want to remember the easiest way on how to build and install custom xDebug without additional troubles in short time. (As I am sure I will forget it if not in written form :-p)

Usually, when installing xDebug to make it work with AMPPS on Mac OSX, I downloaded Komodo Remote Debugging Package and selected version which fit my PHP version and put xdebug.so in my PHP modules directory.

Everything was just fine at the time, until the moment I started to play with Magento 2. I switched the AMPPS PHP version to 5.6 and installed Komodo xDebug as usual. But when tried to debug in PHPStorm, some weird errors appeared and debugging was practically impossible…

After several hours of playing with xDebug settings, I came to the idea to try to build custom downloaded xDebug from source and finally after succeeded, my debugging error is gone with the newest xDebug version installed.

Here are the steps performed:

1. Navigate to xDebug custom installation instructions
2. Navigate to: http://localhost/cgi-bin/phpinfo.cgi in the browser, and select all / copy whole content of the web page
3. Paste that content into textarea on xDebug page we just opened and click on “Analyse phpinfo() output”
4. Now when you have all necessary steps described, just follow the steps to build xDebug.

Is that all?
Why write an article about that?

The answer is simple: using AMPPS on OSX above steps will just not work as we expected to by default. We need to change several things in order to make this process possible.

First of all, try to write in terminal:

which php

If you just have installed AMPPS, I suppose that php command will lead you to /usr/bin/php – which is, in fact, default php from OSX, but we need to get AMPPS’s which is located in /Applications/AMPPS/php/bin/php.

In order to get php from AMPPS it is easiest way to add a line in .bash_profile:

export PATH=/Applications/AMPPS/mysql/bin:/Applications/AMPPS/php/bin:/usr/local/bin$PATH

After that logout and login again. We should have /Applications/AMPPS/php/bin/php displayed when we write:

which php

command in terminal.

Let’s proceed with compiling our xDebug from source now.

Following instructions from xDebug page, unpack downloaded sources and navigate to that folder in terminal.

Next run:


If you get any errors using this command, please use google to find how to resolve them before proceeding.

After phpize, instructions tell us that we need to run


Running that will configure xDebug in a 64bit version which will not work with our AMPPS after compiled. After copying xdebug.so as instructed, try to run

php -v

If you get an error…

Failed loading /Applications/AMPPS/php-5.6/lib/extensions/ext/xdebug.so:  dlopen(/Applications/AMPPS/php-5.6/lib/extensions/ext/xdebug.so, 9): no suitable image found.  Did find:
 /Applications/AMPPS/php-5.6/lib/extensions/ext/xdebug.so: mach-o, but wrong architecture 

… this article is for you.
We need to compile xDebug to 32-bit architecture in order to make it work.

To be honest I Googled a lot on this and finally found a solution which is working for me:

./configure --enable-xdebug CC="gcc -arch i386" CXX="g++ -arch i386"

After the module is built, just continue following instructions on official xDebug site on where to copy it and how to configure in php.ini

And last but not least, I am using following settings in my php.ini:

zend_extension = /Applications/AMPPS/php-5.6/lib/extensions/ext/xdebug.so
xdebug.remote_host =
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req

I hope that this article will help a little bit to save some time on investigating yourselves.