Oh xdebug, where art thou?

I don’t have a stable development environment. I change hardware and software frequently so whenever my wife’s web site needs a revision I usually have to set everything up from scratch. I always develop on a Linux box (I am a Fedora user) and I’ll usually set up an apache server with MySQL running. For development I prefer NetBeans but I’ll use Eclipse if I have to.
For debugging I use XDebug and this is where the fun starts…

It never seems to be a smooth ride getting XDebug up and running, no matter what I do and judging from the many desperate cries for help on various forum threads I am not alone.

This blog post will not solve all your problems with getting xdebug working but I hope it might help you and give you a better set of tools to solve the problem.

The “problem” here manifests itself in NetBeans or Eclipse failing to connect to the debugger.

Firstly, if you have installed xdebug using any of the normal methods and phpinfo() shows an xdebug section then, at least in my experience, you’re good to go and any amount of hacks and fiddling in ini files is unlikely to fix your problem.
It is much more likely then that the problem is external and here is my simple check list of culprits that always seem to be behind my woes, either individually or together;

  • is your firewall allowing port 9000? (the default xdebug port, yours might be different but try not to fiddle with it too much)
  • is SELinux blocking you?

Run your firewall tool of choice (I just run system-config-firewall on Fedora) and check, or add, port 9000. Now try again…if working be happy, else…
Check if SELinux is barking about blocking a “name_connect” and see if port 9000 isn’t mentioned as well. If it is then you need to allow connections, obviously, and since I am not running my Linux box in an environment where I need to be too concerned about paranoid security I just blanket allow httpd (the apache server service I’m running on Fedora) to do whatever it wants;

#setsebool -P httpd_can_network_connect 1

If that doesn’t fix it then I sympathise because nothing is quite as frustrating as struggling with tools when all you want is to get the job done. But, in my humble experience at least, it seems to always end up being something like the above, I.e. something external is blocking xdebug from working. My point is that, unless you have a very peculiar set up, a plain vanilla install of xdebug with the standard ini file entries is fine and you should avoid fiddling with it before you’ve checked the external conditions – even though forum threads out there are quick to suggest it.

Good luck and happy debugging!


Network problem when using VirtualBox HD’s between machines

– Setting up a new VirtualBox machine using a cloned VDI can (will?) cause problems with Linux guest OS’es where the network device fails to initialize resulting in no network connection. The problem is caused by VBox having hard coded the MAC address first assigned to the guest (when the VDI was first created) in “/etc/udev/rules.d/70-persistent-net.rules”
When trying to run the guest with a new machine (from a different VBox instance for example) it mismatches the MAC address and ethX fails to initialize. Trying to “ifup” also fails.

– Take note of the MAC address first assigned by VBox when the VDI and machine is first created and then, for each new machine using that VDI, go to Settings::Network::Advanced and type the MAC address directly into the MAC field.

UPDATE: If you’ve got a VDI that you move around to multiple machines (as I do) and you create new virtual machines to use it with then you want to make sure that each of these new ones use the correct MAC address also, of course, otherwise you have no network. Just create a new machine using said VDI and fire it up. If it’s a Windows machine then you can use ipconfig /all to get the MAC address, otherwise, for Linux, you can use ifconfig or alternatively you can just look at the MAC address setting for eth0 in the /etc/udev/rules.d/70-persistent-net.rules file (there will be lines in there that look something like this:
# PCI device 0x10b7:0x9200 (3c59x) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*",
ATTR{address}=="XX:YY:ZZ:UU:VV:WW", ATTR{type}=="1", NAME="eth0"

and it’s the ATTR{address} field that stores the MAC address.)

– I ran into this because I share VDIs between different machines. I would bring the VDI (for an Ubuntu install for example) to a different laptop and set up a new machine in VirtualBox, using the VDI which I store on a USB drive. It would run but the network card would fail to initialize and running ifconfig would just show me the lo (loop back) device being active. Trying to ifup eth0 just threw up “device not found” errors. At first I hand edited the rules file but then I realized that the simplest (and perhaps most obvious) solution was to just assign the same MAC address to all the new machines myself.

How to set up ipredator VPN, Ubuntu 9.10 (karmic)

First things first, ipredator (http://www.ipredator.se) is a VPN tunnel service that let’s you surf anonymously. It is also in Sweden, which makes a difference (since Sweden have very different laws regarding internet security than for example the UK) and this is A Good Thing if you are concerned about security.

Whatever your reasons you might find yourself signing up for a 3 month subscription with IPREDator, like I’ve done.

The instructions on their web site cover how to set up a VPN connection in Windows (XP+Vista, works for W7 too) and for OSX. Not for Linux though, which is what I have.

So, with your user name and password for your ipredator account at the ready getting it is pretty straight forward to get it going and without any further ado, here it goes:

Install the NetworkManager and the PPTP (Point To Point Tunneling Protocol) extensions:

sudo apt-get install network-manager-gnome network-manager-pptp

You probably have the network manager already, but perhaps not the pptp extension.

Now, restart your network manager:

sudo NetworkManager restart

Select the network manager (either from your launch panel or from System->Preferences->Network connections) and click the VPN tab.

Click “Add” and you should be presented with a form where you can fill in some fields:

Set “Gateway” to “vpn.ipredator.se”

Guess what you need to set “User name” and “Password” too…

Leave “NT Domain” blank.

Give the connection a name or leave it as-is (I called it “IPREDator”…)

Click the “Advanced…” button.

Select “Use Point-to-Point encryption (MPPE)” and leave all other options as-they-are.

You’re done, “ok” your way out of there.

Now you should be ready. In the network manager drop down list of available connections (from the launch panel) you have “VPN Connections” under which you will see your newly added ipredator connection.

Select it and see it think for a while…until it connects and you’re in!


I normally have to try a couple of times before it works. Perhaps it is down to the ipredator server being busy and if the service takes off I hope this will improve. For now I have to retry 2 perhaps 3 times on average before I get the connection.