headbanner

Menu:

nigel-1

Quick Notes:

April 20th, 2008:
Ruby is all syntactic sugar once you get into it. Its not a bad thing, but one should remember that. Rails does too much at run time, and I'm missing JavaScript. Need to finish my XUL based XDebug client for PHP.

Read more...

About Nigel

Nigel is a consultant at ThoughtWorks, seeking a code free nirvana. Unfortunately he's missed the second left.

Previous Posts

- Learning Javascript the right way.

Archives

- August 2007
- October 2007
- January 2008
- February 2008
- March 2008

My choice of links
worth visiting

Check out

- BookEazy
- Intermission
- Sukshma
- CodeWord
- TechCrunch

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]

Hi. You've reached Nigel.in

This site is still in its very early stages, but what you have landed on, possibly inadvertently, is the website of a certain curious character a.k.a Nigel Fernandes

The aim of this page was to serve as a landing point for those of you who want to know a little more about me. The links on the right and left will take you deeper my world, or possibly on to different exciting things.

Its a big web out there and this is just one more street for you to saunter down. I hope you like it.

Close this.

My Photo
Name:
Location: Panjim, Goa, India

Crazy, dancing, programming, Goan.. I'm a computer geek and proud to be one. I program in Java, Ruby and .Net, PHP, Javascript. A lot of my recent work has been about CSS and UI design practices for large scale websites and Agile teams. I still while away hours dreaming up a web startup.

 

Installing Xdebug for PHP on Centos 4 (server)

Friday, August 24, 2007

I needed a good debugging tool for PHP 5, and decided to jump into the world of live debugging. Turns out, in the case of PHP thats not such a hot place to be in. But thats a tale for another day.

After scanning the possible offerings, I narrowed it down to the two main options.
Since Xdebug was open sourced and supported a pretty nice feature list, it was promptly selected.

So then I had to go about getting installed and setup on a Centos 4 based test environment. After some searching I still hadn't found the exact instructions.

So for those of you who need to install Xdebug, here is what you need to do.
  1. You need to have PHP 5 and PECL installed and working with Apache already.
  2. You need to install PHP's devel package. This is needed for the command phpize to work. Note that you need to have the CentosPlus repository enabled for this. So from the terminal as root run the command:
    yum install php-devel
  3. Next you need to have GCC and GCC C++ compilers installed. The only way to install Xdebug on linux as of time of writing this is to compile the extension yourself. The good thing is that this turns out to be is really easy. Note that you also need Autoconf and Automake packages. Once again from the terminal as root run the command:
    yum install gcc gcc-c++ autoconf automake
  4. Next its time to get the Xdebug package for php itself, and compile and install it. That is as simple as typing the following command as root:
    pecl install Xdebug
  5. Now you need to configure your PHP to load the extension. On Centos, extensions are loaded from a folder most likely to be located at /etc/php.d In this folder you are most likely a bunch of .ini files corresponding to what ever extensions you have installed for use with PHP. You now need to create a file called xdebug.ini here as root. Next add the following lines to the file:
    ; Enable Xdebug extension module
    extension=xdebug.so

    ; Configure the extension [See Xdebug documentation for options to add here]
    xdebug.remote_enable=
    xdebug. .....
  6. Restart Apache with service httpd restart and check the output of phpinfo() to see the if Xdebug is loaded and configured correctly.

In case anybody was wondering where the xdebug.so lives on Centos well my system has it sitting at /usr/lib/php/modules/xdebug.so Doing a simple locate xdebug.so should help you locate it.

Anyways this should be enough to get you up and debugging. I still don't have a satisfactory visual client for Xdebug on Linux, but I shall be experimenting with Eclipse's PDT client over the next few days. Will post later on that.

Labels:


Comments:
You should try ProtoEditor :)

http://protoeditor.sourceforge.net/

It's an awesome integration of Kate and debugging support
 
Hi Alexandre.

Thanks for the link. It seems to be a sweet little editor. We are going to put it through its paces in our dev shop and see how it does.

Will post if it meets the bar.

Cheers.
Nigel
 
This was helpful - thanks. I used these instructions for centos 5.3 and they worked fine. I didn't have pecl set up beforehand but "yum install php-pear" was all I needed to get that going. Great post!
 
I used it for Centos 5.3 as well, but I have a problem to run xdebug with apache. When I list packeges in console php -m xdebug is present. php -r "phpinfo();" also show xdebug on the list. When I got some page (use apache) there is no xdebug(is also absent on phpinfo()). What am I doing wrong? Please help.
 
Hi Michael.

Sorry mate, no idea.

Sounds like your apache is loading a different PHP .ini file as compared to command line PHP
 
thanks mate, you is good.

very simple.
 
http://xdebug.org/docs/install

Installing with PEAR/PECL is as easy as:

# pecl install xdebug

but you still need to add the correct line to your php.ini: (don't forget to change the path and filename to the correct one — but make sure you use the full path)

zend_extension="/usr/local/php/modules/xdebug.so"

Dont use
extension=xdebug.so

but instead use

zend_extension=/usr/lib64/php/modules/xdebug.so

in the /etc/php.d/xdebug.ini file
 
Just wanted to add a note here...
I'm using Centos 5.4 with php5.1.6
In order to get my Netbeans debugger to "work" (meaning that it actually stops at the breakpoints), I had to move the xdebug.so file into a sub-directory (I used "/usr/lib/php/modules/Xdebug/xdebug.so") and reference that file from the xdebug.ini file. Not sure why this worked, but just trying to save someone else the time I spent figuring this out.
 
Post a Comment

Subscribe to Post Comments [Atom]





<< Home