Installing xdebug in XAMPP 5.5.19 on Mac OSX

This was tested on OSX Lion. Please let me know if it works on Mountain Lion or later.

Here is what we will be doing in a nut shell. You will need to download the correct source code for your version of xdebug and then you will need to use the correct tools to compile that debug source code to create an extension. You will then install the extension into your version of PHP. Let us begin.

1.) Check to make sure /bin is in your path

echo $PATH;

if :/usr/bin: is in the path then usr/bin is in your path. This makes sure that when you create a symbolic link in usr/bin it can be called from any directory at the prompt.

If it is not in your path you may have your bin directory configured to a different location.

2.) Check to make sure you don't already have phpize installed

sudo cd /usr/bin;
sudo ls -al | grep phpize;

if you get a result like:

-rwxr-xr-x 1 root wheel 4494 Jul 11 2011 phpize

then another version is installed. We don't want to use this version, we want to use the version that came with xampp. so we will rename it to phpize_bkup just in case you ever need to restore it.

sudo mv phpize phpize_bkup;

3.) Create a new symbolic link to phpize in /usr/bin

cd /usr/bin;
sudo ln -s /Applications/XAMPP/bin/phpize-5.5.19 phpize;

4.) Test phpize

cd /;
sudo phpize -v;

you should get something like this:

Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 22012121

5.) Check to see if you have ruby installed

ruby -v;

you should get something like this:

ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin11.0]

If you do not get this then you need to install ruby. For instructions on how to do that look here:


6.) Install homebrew (homebrew is a package manager for mac like yum or apt-get)

Do not install as root that means no sudo or logged in as root.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";

7.) Install autoconfig

brew install autoconf

(Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention. Autoconf creates a configuration script for a package from a template file that lists the operating system features that the package can use, in the form of M4 macro calls.)

8.) install apple Developer Tools

go to https://developer.apple.com/downloads in the web browser
login (you will need your apple ID and password)
select the following on the following screen:


Click the apple in the top left hand corner and select "About This Mac"
Click "More Info"
Find the line that starts with the word "Software"

In my case it is Mac Os X Lion 10.7.5 so I look up that on the downloads page and find the following:

click on the blue link to download the .dmg

go to your Downloads directory and find a file similar to xcode462_cltools_10_76938260a.dmg

double click on the file

double click the file similar to "Command Line Tools (Lion).mpkg" and follow the install guide


9.) get php_info() from your webserver
cd /Applications/XAMPP/htdocs
touch phpinfo.php;
sudo vi phpinfo.php
i
esc
:x!

10.) go to your localhost web root url and run the php file you just created
http://localhost/phpinfo.php
copy the contents of the window (do not copy the html raw source)

11.) now go to debug.org and get the system to tell you which source to download


as soon as you download the source come back here. The instructions it provides will not always work.

12.) Unpack the downloaded file and move into unpacked directory

tar -xvzf xdebug-2.2.6.tgz
cd xdebug-2.2.6

13.) run phpize

phpize

14.) configure specifically for your php version
run inside the xdebug source folder
./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

15.) run make
run inside the debug source folder

make

16.) go back to the debug.org wizard and find the step that has something like this in it

cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212

copy the statement like this and run it in the xdebug folder to move the files over to xampp

17.) edit php.ini

when you edit php.ini
use
sudo vi "$(cd /Applications/XAMPP/; sudo find `pwd` -name php.ini;)"
once in the text editor vi use
/zend_extension
to search for the part to add in the debug extension
i - for the vi command to insert text
if your path that you added to zend_extension= has spaces in it make sure it is surrounded by double quotes, something like the following:
zend_extension="/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so"
esc - to exit insert mode
:x! - to save and exit

This finds the path to php.ini file under /Applications/XAMPP/ and then opens it in the text editor vi, if your php.ini file is not under /Applications/XAMPP/ then change /Applications/XAMPP/ to the location of xampp where you have it installed. If you're confused by Linux voodoo then just find the php.ini file your self go to that directory and type in sudo vi php.ini .

18.) In the text editor vi that has opened php.ini edit the configuration

a.) Find the extension section again by typing the following:

/zend_extension=
i

Note: "/" is for search for string and "i" is for insert which puts you into editing mode.

b.) Add in line at the bottom of the extension section

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.show_local_vars=1
xdebug.remote_log=/Applications/XAMPP/logs/xdebug.log

Remove tabs (\t) at the front when you copy and paste this section in. Other words left justify it.

If your version of xampp is not installed at /Applications/XAMPP/ then replace /Applications/XAMPP/ with your directory

Note: I had to adjust my Net Beans install to use port 9001 in the settings above (see https://netbeans.org/bugzilla/show_bug.cgi?id=176335). I have left the setting above of remote_port to 9000 because that is the norm in most cases.

c.) Add in the xdebug configuration

escape key
:x

d.) Type the following

escape key
:x

19.) Restart the server

sudo /Applications/XAMPP/xamppfiles/ctlscript.sh stop apache
sudo /Applications/XAMPP/xamppfiles/ctlscript.sh start apache

If your version of xampp is not installed at /opt/lampp then replace /opt/lampp with your directory
(I had to do this twice to get it to take)

20.) Check for start up errors in /Applications/XAMPP/xamppfiles/logs/error_log

if you find the following at the time of the last start up:

Xdebug requires Zend Engine API version

then you compiled it incorrectly, go back and scrutinize what you did
if it is not present at the last start up time then you have been successful.

21.) check if installed correctly

go back to the url you created called phpinfo.php
reload the url
copy the contents of the window (again not the html raw source)
and re-analyze your php info to see if debug was installed

22.) Done

Tested on OS X Lion 10.7.5


comments powered by Disqus