DEV Community

Thamaraiselvam
Thamaraiselvam

Posted on

7 2

Configure Xdebug + PHP 7 + Nginx + Any Linux Distribution

Xdebug deepens debugging PHP apps and websites to a level you can’t receive from the manual process of using code level

var_dump()
Enter fullscreen mode Exit fullscreen mode

Get your php.ini

Next output your php.ini information into a file or place you can get the information from. I like to save mine to a file called php-info.txt

sudo php -i > ~/php-info.txt
Enter fullscreen mode Exit fullscreen mode

Use the Xdebug Wizard

Send the text file information into the wizard at Xdebug Wizard. Then follow the instructions the wizard supplies.

Install php-xdebug

This will connect the php with xdebug to the editor also you can configure like editors and remote configurations.

Debian based distributions( Debian, Ubuntu, Linux Mint)

sudo apt install php-xdebug
Enter fullscreen mode Exit fullscreen mode

Arch Linux

sudo pacman -Sy xdebug
Enter fullscreen mode Exit fullscreen mode

Edit xdebug.ini

Now edit the xdebug.ini

sudo nano /etc/php/7.0/mods-available/xdebug.ini
Enter fullscreen mode Exit fullscreen mode

Then paste the following configuration

zend_extension=/usr/lib/php/20151012/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9005 #this can be modified
Enter fullscreen mode Exit fullscreen mode

Restart the services

sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

Configure the editor

In my case, I am using Sublime Text 3 so installed xdebug package using package control

Restart the sublime text.

That’s all. You have configured Xdebug successfully !!!

If you have any issues, Just comment below

this article originally published on Hashnode

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay