I'm trying to do some PHP profiling using Xdebug on a local environment. I'm running Ubuntu 22.04
I'm using PHP-FPM to run PHP v7.2 through a virtualhost.
php -v
outputs
Zend Engine v4.1.7, Copyright (c) Zend Technologies
with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies
with Xdebug v3.1.4, Copyright (c) 2002-2022, by Derick Rethans
On /tmp/xdebug I've run
sudo chown $USER:$USER /tmp/xdebug
At the bottom of my /etc/php/7.2/fpm/php.ini
& /etc/php/8.1/apache2/php.ini
files I've put:
[xdebug]
zend_extension=xdebug
xdebug.output_dir = /tmp/xdebug
xdebug.remote_port=9001
xdebug.mode=develop,trace,profile
I then run
sudo systemctl restart apache2
The enabled Xdebug features are showing up in phpinfo()
in my main /localhost/ directory (using PHP 8.*), but not in the one using PHP 7.2
In my virtualhost .conf file I'm setting the PHP version like (I'm including this because I'm not sure if I need to do anything in this .conf file or not)
<FilesMatch \.php$>
# For Apache version 2.4.10 and above, use SetHandler to run PHP as a fastCGI process server
SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
</FilesMatch>
The image below shows phpinfo()
picking up my Xdebug settings on PHP 8.*; the directory using PHP 7.2 shows no Xdebug settings enabled.
My question(s) / Issues:
I'm using PHP-FPM to run PHP v7.2
PHP 7.2 is no longer supported, so please upgrade to at least PHP 7.4, but preferably PHP 8.0 or 8.1.
the directory using PHP 7.2 shows no Xdebug settings enabled.
php.ini
file — the xdebug_info()
and phpinfo()
sections should show which files it used.systemctl restart
line for Apache does not automatically do that.
sudo chown $USER:$USER /tmp/xdebug
This is unlikely to be correct, as it needs to be the Apache user (often www-data
) that can write to that directory, and not your shell user (which is likely just your log-in username — you can check that with echo $USER
).