Install xdebug on Ubuntu LAMP
Firstly, we need to install php library for xdebug:
sudo apt update
sudo apt install php7.2-xdebug
For other versions of PHP you can use php7.x-xdebug or php5.x-xdebug for PHP 5.x versions.
Further we need to see /usr/lib/php folder and find our xdebug.so file.
cd /usr/lib/php
ls
I have few PHP versions on my local machine, so I have xdebug.so for PHP 7.2 version in 20170718 folder, 20160303 for PHP 7.1 and so on.
Path to xdebug.so must be added to /etc/php/7.2/apache2/php.ini (or any other specified version of PHP):
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.extended_info = 1
xdebug.profiler_output_dir=/tmp
xdebug.idekey = "PHPSTORM"
You can add these settings just to the end of php.ini file. I usually use nano editor to change configs:
sudo nano /etc/php/7.2/apache2/php.ini
Use Ctrl + O for saving changes and Ctrl + X to close nano editor.
After changing configs we need to restart apache:
sudo service apache2 restart
You can also add these settings in cli config, but I don't recommend to do this, because composer works slower with enabled xdebug.
Note: I use PhpStorm IDE, so I added idekey - PHPSTORM, if you use another IDE you should use another idekey, for example ECLIPSE_DBGP or netbeans-xdebug.
You also need chrome extension to enable xdebug for site:
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc