How To Install xdebug on PHP 7.1

Xdebug is a very useful tool when it comes to PHP development, it's a PHP extension that allows you to profile and debug your PHP code. It even allows you to step through your code during runtime to see how it is behaving. I use PHPStorm for my PHP development and when running this with xdebug I'm able to step through the code during runtime inside the IDE and trace the entire application. I mostly use this during writing my unit tests where I can step through the code and see any errors. XDebug is also useful to create code coverage reports using the following library. PHP Code Coverage If you want to know how to install xdebug there is a guide on the xdebug website since version 2.5.0 it will support PHP 7.1. Below is a script you can use to install Xdebug on your machine.


tar xvzf xdebug-2.5.1.tgz
cd xdebug-2.5.1
sudo cp modules/ /usr/lib/php/20151012/
cd /etc/php/7.1/fpm/conf.d/

sudo service php7.1-fpm restart

php -v

sudo sed  -i "|| { s||zend_extension=/usr/lib/php/20151012/| }" /etc/php/7.1/mods-available/xdebug.ini

echo 'xdebug.remote_port=9000'      >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_mode=req'       >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_host=' >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_handler=dbgp'   >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_connect_back=1' >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_enable=1'       >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.remote_autostart=0'    >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.max_nesting_level=400' >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.idekey=PHPSTORM'       >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.default_enable=1'      >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.cli_color=1'           >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.scream=0'              >> /etc/php/7.1/mods-available/xdebug.ini
echo 'xdebug.show_local_vars=1'     >> /etc/php/7.1/mods-available/xdebug.ini

ln -s /etc/php/7.1/mods-available/xdebug.ini /etc/php/7.1/cli/conf.d/20-xdebug.ini

sudo service php7.1-fpm restart

php -v


Reliable uptime monitoring and instant alerts for any website downtime.

  • Uptime Monitoring
  • Performance Monitoring
  • SSL Certificate Alerts
  • Domain Monitoring
  • DNS Checker
  • XML Sitemap Monitoring