‹ jan0sch.de

Lighttpd, newrelic php and per directory settings.

2013-05-28

If you are using lighttpd to host several php applications via virtual hosts and are using the newrelic php monitoring service then you’ll have noticed that setting the php application name per virtual host does not seem possible at first.

I was able to workaround the problem by using the pecl htscanner package. It scans for .htaccess files in your applications directory and imports their settings into you php application.

  1. install the htscanner extension (usually something like sudo pecl install htscanner)
  2. configure the extension
  3. restart lighttpd
  4. create an .htaccess file in your virtual hosts directories

Example .htaccess

php_value newrelic.appname "myapp.example.com"

Example htscanner configuration

This file usually goes to /etc/php5/conf.d/htscanner.ini:

[htscanner]
extension="htscanner.so"
config_file=".htaccess"
default_docroot="/"
default_ttl=300
stop_on_error = 0
verbose = 0