---
title: Use the newrelic-install script for PHP
source: https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/use-newrelic-install-script-php
---

The interactive `newrelic-install` script simplifies installing PHP applications in New Relic. It works with multiple PHP installations as well as installations in non-standard locations. Running it will:

-   Copy the correct PHP modules into place.
-   Install sample `ini` files.
-   Configure the New Relic proxy daemon.

> #### ⚠️ IMPORTANT
>
> Be sure to review the information about [working with multiple installations and non-standard locations](#install-multiple) before running the script.

## Find the installer script [#location]

The installer script location depends on how you installed the New Relic PHP agent.

-   Via system package manager: The installation script is in the `/usr/bin` directory.
-   Via a tarball: The installation script is in the directory where you extracted the `tar` archive file. The script in the `tar` distribution includes installation steps otherwise handled by the package manager.

## Work with multiple PHP installations [#install-multiple]

For `newrelic-install` to correctly detect multiple installations, ensure your `PATH` environment variable is correctly set. The `newrelic-install` script can only install the agent for versions it can find.

| **If you want to...**                 | **Do this...**                                                                                                                                                                                             |
| ------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Specify additional directories        | Use the `NR_INSTALL_PATH` environment variable with a colon-separated list.                                                                                                                                |
| Override `NR_INSTALL_PATH` and `PATH` | Specify a set of directories in the `NR_INSTALL_PHPLIST` environment variable as a colon-separated list. These directories must contain either the command line version of PHP or the `php-config` script. |

## Invoke the installer script [#invocation]

The script has two modes: [install](#install-install) and [uninstall](#install-uninstall). If you invoke it with no arguments, you will be prompted to select a mode.

From the command line, run [the script](https://github.com/newrelic/newrelic-php-agent/blob/main/agent/newrelic-install.sh) at its location:

-   Via system package manager: `/usr/bin/newrelic-install`
-   Via a `tar` archive directory: `./newrelic-install`

## Use the install mode [#install-install]

Follow this process to install New Relic.

**1. Invoke install mode.**

Invoke install mode by using **one** of these methods:

-   Run `newrelic-install` with the `install` command line option.
-   Run `newrelic-install` with no options and select the install option from the main menu when invoking the script.

**2. Provide your New Relic license key.**

At the prompt, enter your New Relic license key. This key will be inserted into any INI files created during the rest of the installation process.

**3. Select which PHP version to use if applicable.**

If `newrelic-install` finds more than one version of PHP, select which version of PHP to use. You will not see this screen if the script only finds a single version of PHP.

**Example:** The menu shows seven options:

````
1)   /usr/bin
2)   /usr/local/php/5.2.16/bin
3)   /usr/local/php/5.2.16-zts/bin
4)   /usr/local/php/5.3.4/bin
5)   /usr/local/php/5.3.4-zts/bin
6)   /usr/local/php/5.4.19-zts/bin
7)   /usr/local/php/5.5.4-zts/bin

0)   Exit

Select (1-7, 0 to exit, or all):
```

ZTS options apply only to [PHP agent versions 9.17 and earlier](/docs/release-notes/agent-release-notes/php-release-notes/php-agent-9170300/). ZTS is not available for PHP versions 9.18 or higher.

At the menu, use any of these options:

* To select only one version, enter the number indicating the version you want to use.
* To select multiple versions, enter a comma- or space-separated list of numbers.
* To select every version listed, enter the keyword `all`.
* To exit the installation process, Enter `0`.

For each directory selected, the script will attempt to install the agent in the proper place and report on each attempt.

<Callout variant="important">
  For PHP installations that allow multiple `.ini` files, the install script will copy a template file into place, if a modified one is not already installed. Make a note of the `.ini` files you will need to modify manually.
</Callout>

As of [PHP agent version 4.0](/docs/release-notes/agent-release-notes/php-release-notes/php-agent-40518), the installer will not work properly if it detects a single version of PHP 5.1, which is deprecated (2013). If you must run PHP 5.1, use [PHP agent version 3.9.5.13](/docs/release-notes/agent-release-notes/php-release-notes/php-agent-39513). If you need help, get support at [support.newrelic.com](https://support.newrelic.com).

````

**4. Install the daemon if applicable.**

If the daemon was not installed by the package manager, install the daemon.

If this is an update or reinstall, the script provide a confirmation prompt before overwriting the old copy of the daemon.

If installation is successful, the script will show this final message:

````
New Relic is now installed on your system. Congratulations!
```

````

**5. Restart your web server.**

To activate the PHP agent, restart your web server.

If you are running PHP-FPM, you may also need to restart PHP-FPM separately before the agent will be active.

**6. Note your archive file.**

Note the name and location of the install archive file. This file will be located at `/tmp/nrinstall-nnnn.tar` and will contain both the install log and useful system information to help New Relic Technical Support with troubleshooting.

**7. Fine-tune your configuration.**

After you install New Relic successfully and restart your web server, you can begin gathering data about your applications. After a few minutes, data will begin to appear on your [APM **Summary** page](https://docs.newrelic.com/docs/apm/apm-ui-pages/monitoring/apm-summary-page-view-transaction-apdex-usage-data/).

To fine-tune operation of both the PHP agent and daemon, review the [PHP configuration options](https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration).

## Use the install_daemon mode [#install-daemon-mode]

To install the daemon without the agent, use PHP agent 9.2 or higher. Run `newrelic-install` with the `install_daemon` command line option.

This is useful if the daemon runs on a different host or in a different container than the PHP application. For example, this may happen with [agent install on containers](https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/install-php-agent-docker).

## Troubleshoot your PHP installation [#troubleshoot]

If there were problems with the installation process, review [No data appears](https://docs.newrelic.com/docs/agents/php-agent/troubleshooting/no-data-appears-php) and other troubleshooting docs before contacting New Relic for support. Be sure to attach your [archive file](#archive-file) to any bug report, as well as the output of the [`phpinfo()`](https://docs.newrelic.com/docs/agents/php-agent/troubleshooting/submitting-troubleshooting-results-php) function produced by your web server.

## Uninstall mode [#install-uninstall]

You can uninstall New Relic but keep valuable config files (useful when upgrading), or permanently uninstall New Relic from your system.

**Uninstall and keep config files.**

This method is useful when you want to uninstall and upgrade. The uninstall does not remove important configuration files, such as your daemon configuration file. Also, it does not remove any `newrelic.ini` files that you have modified.

To uninstall New Relic using the install script, use either of these options:

-   Invoke `newrelic-install` with the `uninstall` option.
-   Run `newrelic-install` with no options, and select the uninstall option from the main menu when invoking the script.

**Permanently uninstall New Relic.**

To permanently uninstall New Relic from your system: Invoke `newrelic-install` with the `purge` option.

This will remove all the configuration files and any links created at installation time. This will **not** affect any configuration parameters placed in files such as `php.in`. Also, this will **not** remove the software packages installed on the system.

To remove the New Relic software packages installed with a package manager, see [Uninstalling RedHat and CentOS](https://docs.newrelic.com/docs/php/php-agent-installation-redhat-and-centos#uninstalling) or [Uninstalling Ubuntu and Debian](https://docs.newrelic.com/docs/php/php-agent-installation-ubuntu-and-debian#uninstalling).
