• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

PHP per-directory INI settings

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.

For more information on PHP-FPM, see PHP-FPM's about page and FastCGI Process Manager on php.net.

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.

Another option is to use the newrelic_set_appname() API call. For other settings that you can modify with the API, see PHP agent API.

Before getting started, we recommend you read the API call guidelines for newrelic_set_appname() to ensure the most complete capture of transaction traces assigned to your application name.

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.

For example:

newrelic.appname="Virtual Host 1;All Virtual Hosts"

This will report to two New Relic applications: "Virtual Host 1" and "All Virtual Hosts".

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.