Profiling with XDEBUG on Debian 11/12 (Apache Webserver)

Posted Saturday 30 October 2021 by Urs Riggenbach.

With a recent Debian upgrade came an upgrade to XDEBUG, a software that can be used for optimizing, debugging and profiling code. I use especially the profiling function, that in combination with kcachegrind shows how long the code is spending on each function, which in turn helps me decide how much time to spend optimizing which function.

Prerequisites for this HowTo are Debian 11 with an Apache 2 Webserver, PHP 7.4.

Install XDEBUG

apt install php-xdebug


Edit the confinguration file

nano /etc/php/*/mods-available/xdebug.ini

Paste the following contents if you want the cachegrind files to appear under /xdebug on the server


xdebug.output_dir = "/xdebug"

xdebug.profiler_enable_trigger = true

#leave empty if you do not want to specify the value
#xdebug.trigger_value = "1"

xdebug.mode = profile

xdebug.start_with_request = trigger



Restart the server, create the necessary directories.

mkdir /xdebug
chmod 777 /xdebug
service apache2 restart


Afterwards, you can add a (GET or POST) parameter to your request to initiate the profiling:

With the new version this also works: