Following on from my previous post detailing Installing Xdebug for PHP (Entropy.ch build) on OS X, this post deals with compiling and installing xdebug 2.0.2 for PHP Version 5.2.5 (www.entropy.ch Release 6) on OS X 10.5.2 Mac Pro 64-bit (2 x Quad-Core Intel Xeon).
The instructions below are a composite of those in the Xdebug README and the user ‘pilif/Philip’ on the entropy forums who posted the CFLAGS settings used to compile Xdebug for x86 64bit architecture (see the post here – thanks Philip!)
The standard release of Marc Liyanage’s PHP Apache Module may not work under OS X 10.5, depending on the architecture of the processor – you will know if you get the error message “The following install step failed: run postflight script for Entropy PHP. Contact the software… “.
Marc has been hard at work compiling an updated 4-way binary and trying to get all the dependencies and packages working – the latest version which I am using (works fine) and which this tutorial is based on is Leopard: PHP 5.2.5 Release 6 BETA
The binary distribution of Xdebug from Activestate which I was using previously won’t work with this version of PHP (I believe I am right in saying it will only work on a 32bit architecture but I may be well wrong) so it needs to be complied from source – luckily it’s pretty easy to do!
First off we need to make sure PHP 5.2.5 from the Entropy site is installed and working, and that the install directory is /usr/local/php5/
Next we need to make sure it is using a php.ini file (probably located at /usr/local/php5/lib/php.ini – if not make a copy of the ‘php.ini-recommended’ file and rename it ‘php.ini’).
We need to make sure that errors are set to be displayed in the ini file (display_errors = On and error_reporting = E_ALL).
The OS X developer tools must be installed (either from the Leopard install disk or the disks which came with the computer).
- Run a phpinfo() page up on the local web server and find the ‘extension_dir’ entry (in the Configuration -> PHP Core section) – copy that value down (it will be something like /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/)
- Download the source code from http://xdebug.org/
- In the terminal, cd into the directory which the source code tar file is in
- Unpack the tarball:
tar -xzf xdebug-2.0.2.tgz - cd into the unpacked directory:
cd xdebug-2.0.2 - Run phpize (using the phpize installed with the Entropy distribution, not the one installed by OSX):
/usr/local/php5/bin/phpize - Configure:
CFLAGS='-arch x86_64' ./configure --enable-xdebug - Run make:
make - Copy the compiled module to the directory you determined in step 1 (replacing the directory shown here with your one if it is differant):
cp modules/xdebug.so /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
Open your php.ini file (for the Entropy version it is at /usr/local/php5/lib/php.ini) and add the following:
[xdebug]
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
(obviously substitute your extensions directory path from stage 1 if it isn’t the same as mine)
- Restart the web server
- Reload the phpinfo() page and look for the ‘Xdebug’ section – if all is working it should show up along with a whole bunch of directives
21 Comments
Thanks for putting up these instructions. It’s nice to finally have my debugger back.
It looks like you missed a step though. After step 7 you need to actually run ‘make’. This is fairly obvious from the instruction, but actually spelling out the command would be useful for a lot of people.
Thank again.
posted by ronan, Mar 8, 08:56 PM
Hi there, thanks for the nice guide.
But I tried this and recieved the same message as before, failed loading (null). Can you please put up a binary of the xdebug.so file?
posted by otto, Mar 15, 03:54 PM
Oops, I was a bit quick on the trigger there. Figured it out two seconds later.
posted by otto, Mar 15, 04:57 PM
@ronan – you are quite right – that wasn’t clear! I have added a ‘make’ step which should hopefully be clearer – thanks for the catch.
@otto – was it the missing step which Ronan pointed out which caught you or was it something else? Is there anything I can do to make the instructions clearer?
posted by James, Mar 15, 09:08 PM
Thanks thanks! I was really struggling to get XDebug installed on my Leopard install of PHP. I really appreciate these instructions. Everything was quite clear as far as I am concerned.
posted by bryan kennedy, May 11, 03:38 AM
I tried again today with xdebug 2.0.3. Everything worked fine, I must have done something wrong the last time.
posted by otto, Jun 13, 04:56 PM
I am a little confused between steps 6 and 8. I downloaded the xdebug source, but get an error when trying to unzip it through the terminal. So I manually unzipped it and cd into the new directory, but do not know what to do from there.
posted by Derek Reynolds, Jul 7, 10:27 PM
@Derek – steps 6 thru to 8 are each commands to enter in the terminal when you are in the directory created by unpacking the tar file – copy & paste into terminal each of the command strings from steps 6-8 (the parts in the monospaced font) and press Return at the end of each in turn to execute them (letting each one do it’s thing before moving on a step).
If you get any errors copy & paste them into a comment here and I’ll see if I can work out what’s going wrong.
posted by James, Jul 8, 11:13 AM
Hi James,
thanks for the guide.
So far its worked beautifully.
I’ve got an issue when I run php -m, it says Failed loading xdebug.so: (null)
The module even comes up when I run a phpinfo().
I’m wondering if you have any advice on this.
thanks heaps,
tony.
posted by Tony, Jul 17, 10:18 AM
Hi,
Need some support here…
I was successfull till Completion of step 8. At the end of step 8 the message says run ‘make test’. When I run ‘make test’ I get the errors listed below. All the 97 test failed.
Any help on this very much appreciated. Thank You. Kumar
——Error —-
Kumar:xdebug Kumar$ make test
Build complete.
Don’t forget to run ‘make test’.
dyld: NSLinkModule() error
dyld: Symbol not found: _OnUpdateBool Referenced from: /Users/Kumar/Downloads/xdebug-2.0.2/xdebug/modules/xdebug.so Expected in: flat namespace
dyld: NSLinkModule() error
dyld: Symbol not found: _OnUpdateBool Referenced from: /Users/Kumar/Downloads/xdebug-2.0.2/xdebug/modules/xdebug.so Expected in: flat namespace
=====================================================================
CWD : /Users/Kumar/Downloads/xdebug-2.0.2/xdebug
PHP : /usr/bin/php
Extra dirs :
=====================================================================
posted by Kumar, Jul 23, 09:14 PM
Thanks, works great!
posted by Juan, Aug 7, 05:44 PM
These were great instructions! However, I have the same issue as Tony (not really an issue). Before, I was able to use the Komodo xdebug.so and was able to see it when running php -m. however i was getting the “failed to load xdebug.so (null)” in my apache error_log. now i have followed your instructions and replaced the komodo xdebug.so with my own built from source but i have the opposite issue. i now can see xdebug in phpinfo().. yay! but when i run php – m i get the “Failed loading xdebug.so (null)” error. Everything is working now but i’m curious about the error, any ideas?
posted by Justin, Sep 10, 12:18 AM
@Tony & @Justin – no idea I’m afraid but I did see this post by Justin Bolterin my referrers which describes what seems to be exactly the same issue you have both been having – Justin says at the end of his post: “The funny thing is now when I run php -m I get the error about loading the xdebug.so extension but everything is working as far as Apache is concerned so I’m happy.”.
@Kumar – sorry I have no idea – but it sounds bad!
posted by James, Sep 21, 10:26 PM
@james thanks for the great write-up solved the one step I was missing.
@Justin I get the same results if I run php -m but that on my system runs the php that came with OSX not the entropy version which isn’t in my path but runs correctly with xdebug by running /usr/local/php5/bin/php -m
posted by Joshua Brauer, Dec 4, 07:29 PM
These were all good tips, but on my Macbook Pro OS X 10.5 I still get no xdebug on apache, but ok on ‘php -m’. All I can think of at this point is to try reinstalling PHP and/or Apache itself. sigh.
posted by Ron Lisle, Jan 18, 12:15 AM
Huge thanks, worked without a hitch!
posted by Michael Arbore, Mar 19, 01:20 PM
Good post..
posted by Wikl, Mar 20, 02:36 PM
Thanks for a great tutorial. At last I have debugging working. A first for me on OS X!
Just a couple of things to point out for beginners:
1) ensure that the xdbug-2.0.4 folder has sufficiently lax permissions to allow the scripts to run (I gave everyone read/write as it is just a working folder). Also, don’t try this on a volume that has a space in the name, as I did (Iomega HDD). There is probably a way around this, but I’m not sure how, not being a command line expert at all. I placed the xdebug folder in my ~/Development folder and all was good.
HTH somebody else.
Thanks again.
posted by Jean-Yves, Apr 24, 03:09 PM
Thanks for the tutorial. I have been trying to get xdebug installed with the “native” php install. It looked fine on the command line but never showed up in the phpinfo. I believe that has to do with the fact that the Leopard kernel is 32 bit and the Apache2 is 64 bits.This install was a brease and now phpinfo shows xdebug installed but php -m on the command line doesn’t show a xdebig module. That is OK as I do not want to use xdebug in Terminal mode. Xdebug now works beautifully on my local server.
Thanks again,
Werner
posted by werner, Apr 29, 10:24 PM
I struggled with the following error when running phpize:
Cannot find config.m4.
Make sure that you run ‘/usr/local/php5/bin/phpize’ in the top level source directory of the module
When I searched the web, I found I was not alone. Note, I unpacked my tar file in a Finder window. I needed to change directories twice since there are two xdebug-2.0.5 directories (e.g., I need to go to the lower level directory to get the phpize command to work).
That said, this probably reflects my lack of compiling skills… :o).
I hope this can help others.
Also thanks for writing up the instructions!!! I really appreciate it.
Mike
posted by Mike, Jul 3, 11:07 PM
For leopard on G5 architecture, you may need to comfigure using this instead:
FLAGS=’-arch ppc64’ ./configure —enable-xdebug
As well, I had to create this file:
/usr/local/php5/php.d/50-extension-xdebug.ini
with these lines:
[xdebug]
zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
(and remove them from php.ini)
Hope this helps,
Nicolas
posted by Nicolas , Nov 4, 09:24 AM