in Debug, Environments, PHP

How to XDebug PHP on production or a remote application

Does you ever had an issue that only appears on production environment? Have you ever felt how easy could be to solve an issue if you can debug the live system instead of the localhost that just works fine?

Debugging a live system can be scary, but it is not if you follow the right steps. Follow this How to XDebug PHP on production and please comment.

Server setup

Check if your SSH Daemon have tcp forwarding enabled:

Please double check that this line it is not commented with an # character, if so edit /etc/ssh/sshd_config  and uncomment it.

Locate where to add xdebug configuration:

Edit /etc/php5/cli/conf.d/20-xdebug.ini  and add the following content:

As you noticed you are editing the php5 cli configuration, but at least in Ubuntu 14.04 LTS the apache2 configuration is linked to the clil using soft links.

Developer host setup

On the developer machine we are going to setup a SSH tunnel to the server. This tunnel will redirect the remote (server) port 9000 to the localhost (developer host) port 9000 in order to connect to the local debugger/IDE.

We can do that with a normal ssh command:

Another option is to configure it on your ssh config file ~/.ssh/config  :

Once you have everything setup you just have to enable your debugger listener, crete the ssh tunnel and enable your XDebug browser helper.

If you enjoyed How to XDebug PHP on production you may also be interested on How to setup XDebug on OSX.

Please share your thoughts and tricks on the comments.

Write a Comment

Comment

  1. Hi

    Thanks for a great tutorial.
    Initially it didn’t work for me, as after changing xdebug settings I forgot to do
    sudo service apache2 restart

    I hope this helps.

Webmentions

  • XDebug and PHP setup for Mac OSX - Albert Sola 18/08/2015

    Hi

    Thanks for a great tutorial.
    Initially it didn’t work for me, as after changing xdebug settings I forgot to do
    sudo service apache2 restart

    I hope this helps.