DEV Community

Thamaraiselvam
Thamaraiselvam

Posted on

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

Top comments (0)