How to install Xdebug on Ubuntu Effortlessly
Tested on: Ubuntu 20 but should work on older versions as well.
Before we set out to install Xdebug on our Ubuntu OS, we need to install a couple packages.
We’ll be using pecl
to install Xdebug. So run the following if you don’t have it installed already (please typepecl
in your terminal to confirm):
sudo apt -y install php7.3-dev php-pear
Replace php7.3-dev
with your php version that your webserver or CGI PM uses.
And finally, run pecl
to install xdebug
:
sudo pecl install xdebug
If all went well, at the end of your installation, you may see this output:
Build process completed successfully
Installing '/usr/lib/php/20180731/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/lib/php/20180731/xdebug.so" to php.ini
As the last line of this installation suggests, we have to place the path to the xdebug extension that we just installed in our php config file:
sudo vim /etc/php/7.3/apache2/php.ini // again, replace 7.3 with your version
Finally, restart your webserver, or PHP-FPM, depending on what you are using.
That’s all. Hopefully, you’ve been able to install Xdebug successfully. And if you have please give this article a thumbs up, I’ll be delighted.
Peace.