---
title: PHP agent installation: Ubuntu and Debian (x86_64)
source: https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-ubuntu-debian
---

Our [PHP agent](https://docs.newrelic.com/docs/agents/php-agent/getting-started/new-relic-php#configuration) auto-instruments your code so you can start monitoring applications. These are the standard procedures to install our PHP agent on Ubuntu or Debian on x86_64 architecture. (This is not the same as the Ubuntu and Debian procedures for the [infrastructure agent](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/installation/install-infrastructure-linux#apt-based).) For installation on aarch64 architecture, please use [tar file](https://docs.newrelic.com/docs/php/php-agent-installation-tar-files) method. For other situations, see the [PHP agent procedures for non-standard PHP installations](https://docs.newrelic.com/docs/php/php-agent-installation-non-standard-php).

## PHP versions [#php7]

The package name for New Relic's PHP agent is `newrelic-php5`. Although the package name references PHP 5, this package works for all [supported PHP versions](https://docs.newrelic.com/docs/agents/php-agent/getting-started/php-agent-compatibility-requirements#php-release).

## Recommended: Use `apt` [#use-apt]

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

> #### ⚠️ IMPORTANT
>
> Run the commands in this procedure as root.

### Configure the New Relic apt repository [#configure-repo]

New Relic's apt repository configuration is only required once per system. To do so, complete these two tasks:

#### 1. Trust the New Relic GPG key

For all Ubuntu releases and Debian releases _before_ Debian Trixie use:

````bash
wget -O- https://download.newrelic.com/NEWRELIC_APT_2DAD550E.public | sudo gpg --import --batch --no-default-keyring --keyring /usr/share/keyrings/download.newrelic.com-newrelic.gpg
```

For Debian Trixie and later use:

```bash
wget -O- https://download.newrelic.com/NEWRELIC_APT_2DAD550E.public | sudo gpg --dearmor -o /usr/share/keyrings/download.newrelic.com-newrelic.gpg
```

This command installs New Relic's GPG key used by `apt` to verify signatures of packages in `http://apt.newrelic.com/debian/` apt repository added in next step.

#### 2. Add `http://apt.newrelic.com/debian/` apt repository to `sources.list`

```bash
echo 'deb [signed-by=/usr/share/keyrings/download.newrelic.com-newrelic.gpg] http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list
```

This command adds `deb [signed-by=/usr/share/keyrings/download.newrelic.com-newrelic.gpg] 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.


````

### Update the local package list [#update-package-list]

Execute the following command as root:

````bash
sudo apt-get update
```
<Callout variant="important">
  If you see this error:
  ```
  Err:8 http://apt.newrelic.com/debian newrelic Release.gpg
  The following signatures were invalid: B60A3EC9BC013B9C23790EC8B31B29E5548C16BF (untrusted public key algorithm: dsa1024)
  ```
  or this error:
  ```
  Err:8 https://apt.newrelic.com/debian newrelic Release.gpg
  The following signatures were invalid: B60A3EC9BC013B9C23790EC8B31B29E5548C16BF (untrusted public key algorithm: dsa1024) The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 32FA4C172DAD550E
  ```
  please make sure you have the correct New Relic GPG key installed. See the [Trust the New Relic GPG key](#1-trust-the-new-relic-gpg-key) section for instructions how to install the New Relic GPG key.
</Callout>

````

### Install the PHP agent [#install-php-agent]

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

````bash
sudo apt-get install newrelic-php5
```

````

### Non-standard installations: Complete installation manually [#manual-install]

If you are not using the default Ubuntu or Debian PHP packages, the `newrelic-php5` package may be unable to configure PHP automatically. You may see this error:

````
Please run newrelic-install as root to complete installation.
```

If so, run the following command:

```bash
sudo newrelic-install install
```

````

### Configure your application name and New Relic license key [#license-key]

The installation process prompts for your application name and license key. Your license key appears in the account information section of **Account settings**. For headless installations, you can also [preconfigure your license key and application name by using `debconf`](#preseeding).

### Restart your web server or FastCGI Process Manager (FPM) [#fpm]

Generate traffic for your app, and wait a few minutes for your application to send data to New Relic. Then, [check your app's performance in the New Relic UI](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/apm-overview-page).

## Optional: Unattended installation [#unattended]

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

```bash
DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5
```

## Manual: Use `dpkg` [#use-dpkg]

> #### ⚠️ IMPORTANT
>
> If you use `dpkg`, you must manually install updates. This is why New Relic recommends the [`apt` method](#use-apt) for installation and maintenance. Run the commands in this procedure as root.

To install the PHP agent manually using `dpkg`:

### Copy the URL for the package download [#copy-package]

Copy the full URL for the latest `newrelic-daemon`, `newrelic-php5-common`, and `newrelic-php5` packages from [New Relic's repository](https://apt.newrelic.com/debian/dists/newrelic/non-free/binary-amd64/)

### Download the package [#download-package]

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

````bash
wget -L https://LINK_TO_PACKAGE
```

````

### Install the PHP agent [#manual-install]

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

````bash
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
```

````

### Configure your application name and New Relic license key [#configure-key]

The installation process prompts for your application name and license key. Your license key appears in the account information section of **Account settings**. For headless installations, you can also [preconfigure your license key and application name by using `debconf`](#preseeding).

### Restart your web server or FastCGI Process Manager (FPM) [#restart-server]

Generate traffic for your app, and wait a few minutes for your application to send data to New Relic. Then, [check your app's performance in the New Relic UI](https://docs.newrelic.com/docs/apm/applications-menu/monitoring/apm-overview-page).

## Headless: Preconfigure license key and app name [#preseeding]

For headless installations, you need to take steps to preconfigure your license key and [application name](https://docs.newrelic.com/docs/site/naming-your-application). You must use the default php5 packages provided by your distribution. To preconfigure the license key and application name, set values in your `debconf` database by using [`debconf-set-selections`](https://manpages.debian.org/bookworm/debconf/debconf-set-selections.1.en.html).

> #### ⚠️ IMPORTANT
>
> These settings will be ignored if you are not using a packaged PHP. 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`](/docs/php/php-agent-phpini-settings#inivar-appname) in your `newrelic.ini`.  ````               | string |
| ```` newrelic-php5/license-key ```  Your <InlinePopover type="licenseKey"/>. This string sets [`newrelic.license`](/docs/php/php-agent-phpini-settings#inivar-license) in your `newrelic.ini`.  ```` | string |

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

```bash
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
```
