Install Xdebug with php-fpm per pool

From Brian Nelson Ramblings
Jump to: navigation, search

Install Xdebug with php-fpm per pool

Ever need to install xdebug to create cachegrind files for only specific php-fpm pool

Install Xdebug

Fastest way to install xdebug

pecl install xdebug

Or if you're using SCL with multiple version

scl enable <phpverson> 'pecl install xdebug'

Configure xdebug.ini

We only want specific php-fpm pools to create cachegrind files

zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.profiler_enable = 0
xdebug.profiler_output_name = "cachegrind.out.%H.%p"
xdebug.profiler_enable_trigger = 0

You might have to change the zend_extension location to match your location

Configure php-fpm pool

Add the following to your php-fpm pool config:

php_admin_flag[xdebug.profiler_enable_trigger] = On
php_admin_value[xdebug.profiler_output_dir] = /home/<user>/xdebug
php_admin_flag[xdebug.remote_enable] = On;

Again you can change the output location by changing the php_admin_value[xdebug.profiler_output_dir]

Then make the output directory:

mkdir /home/<user>/xdebug

Create cachegrind files

Then use the following flag to create the cachegrind file

http: / /<domain>/?XDEBUG_PROFILE=1 or any page with ?XDEBUG_PROFILE=1