Wednesday, January 19, 2011

Setting up PHP Code Profiling with Xdebug

I recently installed Xdebug on my server with the intention of using it for code profiling. It seems to be installed correctly, and phpinfo lists the following:

xdebug.profiler_enable       On                       On  
xdebug.profiler_enable_trigger Off                    Off  
xdebug.profiler_output_dir   /var/www/vhosts/xdebug   /var/www/vhosts/xdebug  
xdebug.profiler_output_name cachegrind.out.%p        cachegrind.out.%p

However, I can't figure out for the life of me why no cachgrinds are being created when I run the PHP scripts.

Is there something I'm missing, or understanding incorrectly?

  • Try removing the options

    xdebug.profiler_enable_trigger Off                    Off  
    xdebug.profiler_output_dir   /var/www/vhosts/xdebug   /var/www/vhosts/xdebug  
    xdebug.profiler_output_name cachegrind.out.%p        cachegrind.out.%p
    

    The first is a default anyway, so it's redundant. Removing the other 2 will allow you to figure out it the problem is with those options, or something else.

    Restart Apache, hit a php page and see if any output is generated in /tmp. this is the default location for output logs.

    If there is something generated, then you can be fairly certain it is a permissions issue with your output directory.

    Check the owner of the file generated in /tmp and be sure that user has write permissions on /var/www/vhosts/xdebug (from your original config) and re-add the options you had initially.

    From LukeR

0 comments:

Post a Comment