Setting up Xdebug on ubuntu 10.10 lamp stack

I setup Xdebug recently to profile a drupal page that was exceedly slow.  I'm running ubuntu 10.10 with a typical lamp stack and did the following:

apt-get update

apt-get install php5-dev php-pear

pecl install xdebug

locate xdebug.so (should look something like this: /usr/lib/php5/20060613/xdebug.so)

Add the following line to php.ini (zend_extension="/usr/lib/php5/20060613/xdebug.so")

/etc/init.d/apache2 restart

Check your phpinfo to ensure xdebug has been sucessfully installed

Create an xdebug.ini file and place it into your php conf.d directory containing the following lines for enabling profiling:

; The extension itself
zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so

; I tried to get this setting to work but had no luck
; The idea is that the server will auto detect the client IP
; and save you having to specify it explicitly with the remote_host
; setting.

; xdebug.remote_connect_back = 1

; Basic settings. To turn on xdebug
; As mentioned the IP is your clients

xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_log = /var/www/xdebug.log

; I have xdebug automatically start trying to
; connect to a client.

xdebug.remote_autostart = 1

; These parameters are if you want to use the profiler
; Not needed for the debugger, but very usful in conjunction with
; kcahcegrind for getting visual maps of where program execution is
; taking time
; xdebug.profiler_enable = 1
; xdebug.profiler_output_dir = /var/www/dumps/xdebug/


; These parameters are for the tracing feature again not needed
; for debug. Produces REAMS on info on memory usage.

;xdebug.auto_trace = 1;
;xdebug.trace_format = 0;
;xdebug.collect_assignments=1;
;xdebug.show_mem_delta = 1;
;xdebug.collect_params = 0;
;xdebug.trace_output_dir = /var/www;
;xdebug.trace_output_name= trace_%s_;

Run a page and you will have a file in the output directory setup in the xdebug.ini file.

Use the kcachegrind application to read the file created by Xdebug.