PHP agent installation: Ubuntu and Debian

This procedure is for installing New Relic APM's PHP agent using Ubuntu or Debian. This is not the same as the Ubuntu and Debian procedures for New Relic Infrastructure.

Use apt (recommended)

This is the recommended method for New Relic installation and maintenance.

Run the commands in this procedure as root.

Step Notes
1.

Configure the New Relic apt repository.

echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list

This command adds deb http://apt.newrelic.com/debian/ newrelic non-free to /etc/apt/sources.list.d/newrelic.list. It creates the file if it does not exist.

This step is only required once per system.

2.

Trust the New Relic GPG key.

This step is required to register New Relic as an authenticated source where apt-get will look for new packages. To get the New Relic public apt-key from global key servers, run the following command as root:

wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -

If you do not run this command as root, you may see an error message about the public key.

3.

Update the local package list.

Execute the following command as root:

sudo apt-get update
4.

Install the PHP agent.

Execute the following command to install directly from the New Relic repositories:

sudo apt-get install newrelic-php5

The newrelic-php5 package may be unable to configure PHP automatically if you are not using the default Ubuntu or Debian PHP packages. In that case, you may see this error: "Please run newrelic-install as root to complete installation."

If so, run the following command:

sudo newrelic-install install

To run an unattended installation, you can use non-interactive mode and use the -y flag to automatically respond yes to any prompt during package installation. For example:

DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5
5.

Configure your application name and New Relic license key.

The installation process prompts you for your application name and license key. Your license key appears in the account information section of Account settings.

You can also preseed your license key and application name via debconf for headless installations.

6.

Restart your web server or FastCGI Process Manager (FPM).

Wait a few minutes for your application to send data to New Relic. Then, check your app's performance in the New Relic UI.

Use dpkg (manual installation)

If you use this method, you will need to manually install updates. That is why the apt method above is the recommended installation and maintenance method. Run the commands in this procedure as root.

Step Notes
1.

Copy the URL for the package download.

Navigate to the appropriate URL for your architecture and copy the full URL for the latest newrelic-daemon, newrelic-php5-common, and newrelic-php5 packages:

2.

Download the package.

Run the following wget command, replacing https://LINK_TO_PACKAGE with the full URL of the package:

wget -L https://LINK_TO_PACKAGE
3.

Install the PHP agent.

Run the appropriate command as root, replacing X.X.X.X with the current version:

32-bit:

dpkg -i newrelic-php5-common_X.X.X.X_all.deb newrelic-daemon_X.X.X.X_i386.deb newrelic-php5_X.X.X.X_i386.deb

64-bit:

dpkg -i newrelic-php5-common_X.X.X.X_all.deb newrelic-daemon_X.X.X.X_amd64.deb newrelic-php5_X.X.X.X_amd64.deb
4.

Configure your application name and New Relic license key.

The installation process prompts you for your application name and license key. Your license key appears in the account information section of Account settings.

You can also preseed your license key and application name via debconf for headless installations.

5.

Restart your web server or FastCGI Process Manager (FPM).

Wait a few minutes for your application to send data to New Relic.

Preseeding the license key and application name

You can preseed your license key and application name for headless installations. This requires that you use the default php5 packages provided by your distribution. To preseed, set values in your debconf database via debconf-set-selections.

These settings will be ignored if you aren't using a packaged PHP, and you will be prompted to run newrelic-install.

These keys are located in the newrelic-php5 package:

Name Type
newrelic-php5/application-name

The name of your app. This string sets newrelic.appname in newrelic.ini.

string
newrelic-php5/license-key

Your New Relic license key. This string sets newrelic.license in newrelic.ini.

string

For example, you can run these commands to preseed your app name and license key:

echo newrelic-php5 newrelic-php5/application-name string "My App Name" | debconf-set-selections
echo newrelic-php5 newrelic-php5/license-key string "YOUR_LICENSE_KEY" | debconf-set-selections

For more help

Additional documentation resources include:

Join the discussion about PHP in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.