22 October 2013

How to install Xdebug with Sublime Text in Ubuntu 12.04


Xdebug is a PHP extension for powerful debugging. It supports stack and function traces, profiling information and memory allocation and script execution analysis. Xdebug provide following functionality like function name, file name and line indications, support for member functions, full parameter display for user defined functions etc for PHP developers which help them to debug their code easily and quickly.

Installing Xdebug with Sublime Text in Ubuntu is little bit tricky, but you can easily install it if you follow along this post. Lets get started.

Installing Xdebug in Ubuntu

Step 1: Open terminal(Ctrl + Alt + t) and type following command to see whether Xdebug is installed or not.
$ php -v
PHP 5.3.10-1ubuntu3.8 with Suhosin-Patch (cli) (built: Sep  4 2013 20:00:51) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
Note: If your Output is same like mine then you are good to go. If not the type following command to install it.
$ sudo apt-get install php5-xdebug

Step 2: Find the location of "xdebug.so" using following commad
$ sudo find /usr/lib/php5 -name 'xdebug.so'
Note: If you don't find the path of the file using the above command, use following command to search in entire file system
$ sudo find / -name 'xdebug.so'
Step 3: Next step is to edit xdebug.ini file using the following commands
$ cd /etc/php5/apache2/conf.d
$ sudo gedit xdebug.ini
Add following lines to xdebug.ini file
xdebug.max_nesting_level = 200
xdebug.remote_connect_back = 1
Note:In zend_extension field enter your xdebug.so file path. If you want to know what all this means, you can refer Xdebug official website.

Step 4: Restart your apache web-server
$ sudo service apache2 restart

Integrating Xdebug with Sublime Text

We successfully installed Xdebug in Ubuntu, lets integrate it with sublime text

Step 1: Open Sublime text, open package manager (Ctrl + shift + p), type install packages and select xdebug client.

Step 2: Next step is to edit xdebug configuration file. Go to tools->xdebug->default setings and in url field enter the url which you want to debug.

Step 3: Add break point and start debugger using start debugging(launch browser) option.

That's it. Happy Debugging.
Enjoy :)

If You Liked This Post Please Take a Time To Share This Post

You May Also Like...


  1. Hello. I have tried to run "start debugging(launch browser)", but browser not opening.
    What is wrong? May be i need to add something to php.ini?
    I have just this: https://db.tt/9N367hd2

    My system is Elementary OS Luna (based on ubuntu 12.04).
    Please, help me. :)

    1. Please check whether you have installed xdebug client or Xdebug plugin. If you have installed xdebug then uninstall it and install xdebug client.
      Sorry for late reply

    2. I have installed XDebug Client, but it doesn't work. :(

    3. Sorry then i have no idea why it is not working in your system

  2. If you are using a separate system to trigger the calls, do not enable remote callback. Instead, your settings could look like this:

    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1
    xdebug.remote_handler = dbgp
    xdebug.remote_host =
    xdebug.remote_log = /tmp/xdebug_remote.log
    xdebug.remote_mode = req
    xdebug.remote_port = 9001