Most PHP agent configuration variables can be set on a per-directory basis. This option is often used when there is a single web server serving multiple applications, and you want to adjust settings (for example, the app name) on an application-by-application basis.
The process for setting per-directory values depends on the environment. This document describes the three most common environments:
For other app naming options, see Name your PHP application.
Apache per-directory settings for PHP
When using the PHP module, Apache provides two mechanisms for setting PHP variables outside the INI file:
PHP-FPM per-directory settings
The FastCGI Process Manager (PHP-FPM) is dedicated to PHP. It spawns a number of worker processes that wait for requests. It increases performance by not re-initializing the PHP engine on each invocation, allowing each process to deal with a number of requests before it recycles.
When using PHP-FPM, there are two mechanisms for setting PHP variables outside the INI file and one special technique for NGINX:
Another option: API calls
Although we recommend changing the application name with global or per-directory INI settings, in some cases that may not be possible. For example, provider limitations may prevent you from modifying configuration files.
If you don't have access to the code for your application, or if you need to isolate your applications to their own virtual hosts for other reasons, then use the following per-directory settings to override any configuration file settings.
Roll-up application names
If you want to have an overall view of how the server is performing across all virtual hosts or all applications, it is convenient to be able to report to more than one application at a time. For example, report to a virtual host specific application as well as a roll-up application.
To do this, set more than one application name for the
newrelic.appname parameter by separating each application name with a semicolon. The primary application name is first, and the secondary application names next. You can define up to two extra application names.
newrelic.appname="Virtual Host 1;All Virtual Hosts"
This will report to two New Relic applications: "Virtual Host 1" and "All Virtual Hosts".
This feature is only available in versions 2.4 or higher of the PHP agent.