Drupal Profiling with XHProf on Ubuntu 11.10 + Memcached and Varnish

  1. Install memcached, varnish, and xhprof

    sudo apt-get install memcached
    sudo apt-get install php5-memcached
    sudo apt-get install varnish
    sudo pecl install php-xhprof

  2. Install xhprof front-end

    cd /var/www
    git clone https://github.com/facebook/xhprof.git

  3. Configure Apache and Varnish ports

    sudo vim /etc/apache2/ports.conf ; // Change 80 to 8080
    sudo vim /etc/apache2/sites-available/default // Change 80 to 8080
    sudo vim /etc/default/varnish // Change 6081 to 80

  4. [Re]start services

    sudo service memcached start
    sudo service varnishd start
    sudo service apache2 restart

  5. Download and install memcache, varnish (and devel) drupal modules:

    drush dl memcache varnish devel -y

  6. Configure Drupal for Memcached

    sudo vim .../sites/site/settings.php:
    $conf['cache_inc'] = '/path/to/memcache/module/cache.inc';
    Configure settings at /admin/settings/memcache

  7. Configure Drupal for Varnish

    Get contents of /etc/varnish/secret and settings from /etc/default/varnish
    Enter them at /admin/settings/varnish.

  8. Configure Devel module for XHprof integration:

    Enable XHprof integration (checkbox).
    Enter path to xhprof and xhprof_html at /admin/settings/devel.

Now see XHProf output link at bottom of pages.


  1. http://transparatech.com/blog/xhprof-install-secrets-revealed-oooh
  2. http://code.google.com/p/memcached/wiki/NewStart
  3. http://drupal.org/node/946182