Install Xdebug on Hypernode Vagrant

in Tools

Xdebug is a debugger for PHP. It can be used to retrieve extended debug information and stacktraces from your development environment and send it to a log file or to your IDE or browser. As Xdebug has a massive performance impact, it’s not possible to use this debugger on the Hypernode itself.

Xdebug is already installed on Hypernode Vagrant. If you prefer a newer version, you can use this howto to manually build and install xdebug.

Prerequisites

First, setup your Vagrant node and copy your Magento to the Hypernode Vagrant.

Now login as user Vagrant and use sudo to become root:

vagrant ssh
sudo su

Install Xdebug

Install all required packages:

  • For PHP7:
apt-get update
apt-get install php7.0-dev
  • For PHP5:
apt-get update
apt-get install php5-dev

Download Xdebug

First we download the latest version of Xdebug. This version can change in time, so check the Xdebug Website to get the preferred sources.

Download the source tarbal:

wget -O /tmp/xdebug.tgz https://xdebug.org/files/xdebug-2.5.0RC1.tgz 
cd /tmp/
tar -xvzf xdebug.tgz
cd xdebug-2.5.0RC1

Build Xdebug from source

When Xdebug is downloaded and unpacked, we can build the extension. This works the same on all PHP versions:

 phpize
 ./configure
 make

Move xdebug.so in place:

  • For PHP7:
cp modules/xdebug.so /usr/lib/php/20151012/
  • For PHP5:
cp modules/xdebug.so /usr/lib/php5/20121212/

Load the Xdebug PHP extension in your PHP settings

After building, load the zend_extension for both CLI and FPM:

  • For PHP7:
for i in fpm cli; do
    echo -n "zend_extension = /usr/lib/php/20151012/xdebug.so" | tee \
    /etc/php/7.0/${i}/conf.d/10-xdebug.ini
done
  • For PHP5:
for i in fpm cli; do
    echo -n "zend_extension = /usr/lib/php5/20121212/xdebug.so" | tee \ 
    /etc/php5/${i}/conf.d/10-xdebug.ini 
done

And after that restart PHP-FPM and Nginx:

  • For PHP7:
sudo service php7.0-fpm restart
sudo service nginx restart
  • For PHP5:
sudo service php5-fpm restart
sudo service nginx restart

That’s it 🙂 Xdebug is now installed and configured.

Configuration

See Configuring Xdebug for configuring xdebug and examples to send debug data to your IDE.

1