Home » Php » PHP Xdebug on OS X 10.9 Mavericks

PHP Xdebug on OS X 10.9 Mavericks

Posted by: admin April 23, 2020 Leave a comment


I’m having issues setting up my PHP development environment on OS X after installing OS X 10.9 Mavericks.

Here is the command I am using to install.

sudo pecl install xdebug

downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

Anyone have a solution or a workaround?

How to&Answers:

The fast copy-paste way

sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'

This command do the following :

  • Finds the native Xdebug extension that comes with Xcode
  • Asks php which config file is loaded
  • Adds the Xdebug extension path in the config file
  • Restarts apache.

Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.

Before launching the command, make sure Xcode command line tools are installed : xcode-select --install


Don’t know about using pecl. Getting Xdebug after an OS X install is pretty straightforward without pecl. You’ve got two easy options:

  1. Use the version already available at:

  2. Build your own:

    1. Make sure you have the Xcode CLI tools: xcode-select --install will prompt you to install the CLI tools. With the CLI tools installed, there should be stuff inside /usr/include/php.

    2. Go to http://xdebug.org/download.php and download the source tarball for the version of Xdebug you want. For example: http://xdebug.org/files/xdebug-2.2.3.tgz.

    3. Extract the tarball and cd into the directory it created. Inside that directory you’ll see a README. From here it’s:

      $ phpize
      Configuring for:
      PHP Api Version:         20100412
      Zend Module Api No:      20100525
      Zend Extension Api No:   220100525
      $ ./configure --enable-xdebug
      checking for grep that handles long lines and -e... /usr/bin/grep
      checking for egrep... /usr/bin/grep -E
      checking for a sed that does not truncate output... /usr/bin/sed
      [... output ...]
      $ make
      [... output ...]

Your built xdebug.so is now at modules/xdebug.so. The phpize is critical to do with XCode CLI tools installed, because phpize sets up the build parameters for your version of PHP.

With your xdebug.so in hand from (1) or (2) above, you can add this block to the php.ini being used by your php or php-fpm:

xdebug.remote_host=<host running PHP (e.g. localhost)>
xdebug.remote_port=<port Xdebug tries to connect to on the host running PHP (default 9000)>


There are two issues here. The first is that you need to install Xcode command line tools with the command:

xcode-select --install

This will mean that the files previously not found in /usr/include/php/ will be available.

The next step is to install autoconf in the same way as Ares shows in his answer.

I would cd into your download folder first

cd ~/Downloads/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
sudo make install

now you can run the pecl install command

sudo pecl install xdebug


If you are using Mac Yosemite 10.10 and none of the above answers solved the problem. Do the following:

  1. Open a terminal

  2. Execute find /usr/lib/php/extensions -name "xdebug.so" to know the path to the debug library.

  3. Execute sudo nano /etc/php.ini to open and edit the php.ini file
  4. In php.ini add the following lines at the end


(When finished, type control+o to save and control+x to close the file)

(Don’t forget to replace the value in zend_extension for whatever you got from the first terminal command)

  1. Execute sudo apachectl restart to load the new configuration
  2. Sit back and relax


For anyone who is facing this issue I had to build autoconf from source. I followed this answer from another StackOverflow question.



For the issue phpize error,try this will solve your problem:
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include


I had to brew install xdebug and choose for my version of PHP and it worked!
For example,

brew install homebrew/php/php56-xdebug

For a PHP version 5.6 variant.