Geeky Nuggets

Remote debugging with Xdebug and PhpStorm on Ubuntu

August 18, 2011 | 3 Minute Read

Being able to debug your php application right from your IDE is something that you can’t fully realise the power of, unless you’ve tried it. The advantages are immediately obvious: as soon as the connection from Xdebug is successful, you are blinded by variable inspection, code stepping, breakpoints, etc… Debugging heaven! It took me… a few months to finally find the time figure out how to set up everything properly, so I hope this post can help someone, somewhere. But don’t worry: it retrospect, it’s not that difficult at all.

First things first : install xdebug

On Ubuntu and Debian, it couldn’t be easier: just open a terminal and type

sudo apt-get install

This will also install Apache and PHP if you don’t have them already.

Setup Xdebug on server

Done? Right, so this created a config file in /etc/php5/conf.d called xdebug.ini, which is read by php and contains xdebug’s configuration options. You’ll need to open this file for editing as root, as we need to make a few changes in there. you can copy/paste the command below in the terminal, or do it your own way.

gksu gedit /etc/apache2/conf.d/xdebug.ini

Within this file, there will be a single line, referencing the xdebug zend extension, something like this (the path can vary slightly)


This is what we’re going to add:

xdebug.remote_enable=On #this enables remote debugging

xdebug.remote_host= #change this IP adress for the one of the computer you are typing on

xdebug.remote_port=9000 #this is the default, leave it as is

Now we restart apache so that the new configuration is taken into account:

sudo /etc/init.d/apache2 restart

And we that we are done on the server side of things

Prepare PhpStorm

Switch to the computer where PhpStorm is installed, and open your project. All you have to do is click on the “Accept debug connections” button, and activate Xdebug by using a browser extension. Here are four extensions to do this:

Use your preferred extension to activate Xdebug for the page you’re on. Go back to PhpStorm, and instruct it to listen to incoming debug connections by clicking on the “Listen PHP debug connections” button

Now all you have to is set a breakpoint and reload your page.

Setting a breakpoint in PhpStorm
Setting breakpoint

A window will popup asking you if PhpStorm should accept the connection from Xdebug

Accepting connection from Xdebug on PhpStorm
Accepting connection from Xdebug

Just click debug and happy bug squishing!