• /
  • Log in
  • Free account

Docker and other container environments: Install PHP agent

You can install the PHP agent on a Docker container or other container to monitor one or more of your PHP applications. This is supported for containers that meet PHP agent requirements.

Tip

To use PHP or any other agent, as well as the rest of our observability platform, join the New Relic family! Sign up to create your free account in only a few seconds. Then ingest up to 100GB of data for free each month. Forever.

Container options

The PHP agent requires two components to work: the PHP agent (one for each application) and a daemon, which aggregates data sent from one or more agents and sends it to New Relic. For this reason, there are two options for enabling the PHP agent for container environments:

Install agent and daemon in different containers

Requirements:

To see an example application, go to New Relic's Explorers Hub.

Caution

Data transmitted from the agent to the daemon is not encrypted. The only exception to this is the SQL obfuscation that happens before sending data to the daemon. If the agent and daemon are running on different hosts, we recommend that you use a private network connection between the agent and daemon.

Set up the daemon container

If you use Docker, you can pull our daemon image from Docker Hub:

  1. Run this command: docker pull newrelic/php-daemon.
  2. To customize the image, follow the steps on Docker Hub.

You can also build your own daemon image:

  1. To install the daemon, download the PHP agent package from New Relic's tar file download site, and run the newrelic-install script with the install_daemon argument.
  2. Start the daemon using --address and --watchdog-foreground arguments.

The --address argument sets a port for the daemon to accept connections. The --watchdog-foreground argument ensures that the daemon runs in the foreground.

Set up the PHP agent container

To set up the PHP agent container for Docker:

  1. Make sure a PHP installation is available in the container. For example, use a published Docker image like php:7.1.
  2. To install the agent, download the PHP agent package from New Relic's tar file download site, and run the newrelic-install script with the install argument.
  3. In the newrelic.ini file, set the application name and license key with the newrelic.appname and newrelic.license entries .
  4. Point the agent to the daemon by setting the newrelic.daemon.address option in the newrelic.ini file. Make sure the value for this option is HOST:PORT, where HOST is the name or IP address of the host where the daemon is running, and PORT is the port number where the daemon is listening

Install agent and daemon in the same container

To set up the PHP agent and daemon in the same Docker container:

  1. Make sure a PHP installation is available in the container. For example: you might use a published Docker image like php:7.1.
  2. To install the agent, download the PHP agent package from New Relic's tar file download site and run the newrelic-install script with the install argument.
  3. Set the application name and license key via the newrelic.license and newrelic.appname entries in the newrelic.ini file.
  4. By default, the first transaction causes the agent to trigger a daemon start and an application connection initialization. However, for performance reasons, the agent does not wait for those operations to complete before it initializes the connection, which can result in the loss of the first few transactions after a container starts. To prevent this, set both newrelic.daemon.start_timeout and newrelic.daemon.app_connect_timeout entries in the newrelic.ini file to recommended values.

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.