---
title: PHP agent installation: Non-standard PHP (advanced)
source: https://docs.newrelic.com/docs/apm/agents/php-agent/advanced-installation/php-agent-installation-non-standard-php-advanced
---

If you are using a non-standard PHP installation, follow this procedure to properly install New Relic. This is common in instances where the default installer does not find your PHP installation (for example, if you have self-compiled PHP or a self-contained PHP stack).

> #### ⚠️ IMPORTANT
>
> As part of the installation process, change the default [application name](https://docs.newrelic.com/docs/site/naming-your-application) to a meaningful name.

## Requirements [#prep]

Use the command line version of PHP (`php -i`) or look at the output of `phpinfo()` to determine:

-   The PHP extension version (`20090626`, `20100525`, `20121212`, `20131226`, `20151012`, or `20160303`)
-   The extension or module installation directory
-   Whether or not your version of PHP has been compiled with ZTS (Zend Thread Safety) support

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

## Use the command line newrelic-install script (recommended) [#script]

1.  Point New Relic at the right directory by using any of these options:

    **Add your PHP location to your PATH**

    The install script needs to be able to find your command line `php` or `php-config`. You can add the directory that contains those programs to your current `PATH`.

    **Set the NR_INSTALL_PATH**

    This can be a colon-separated list of directories for PHP installations in addition to those in your `PATH`. Make sure these directories contain `php` or `php-config`. For example:

    ````bash
    NR_INSTALL_PATH=/u/php/5.3/bin; export NR_INSTALL_PATH
    newrelic-install
    ```

    ````

    **Set the NR_INSTALL_PHPLIST**

    Optional: Use a colon-separated list to set the exact locations (directories) where to search. This option will ignore `PATH` and `NR_INSTALL_PATH`. For example:

    ````bash
    NR_INSTALL_PHPLIST=/usr/local/bin:u/php/5.3/bin; export NR_INSTALL_PHPLIST
    newrelic-install
    ```

    ````
2.  Invoke the `newrelic-install` script from its directory. Depending on your server and your paths, the install script may find other versions of PHP on your system. Select your specific version from the list.

For more information, see [PHP install script](https://docs.newrelic.com/docs/agents/php-agent/installation/newrelic-install-script).

## Install New Relic manually [#manual]

If you do not want to use the install script, you can perform a fully manual installation. Be sure to gather [information about your PHP installation](https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/php-agent-installation-non-standard-php-advanced/#prep). You can review and obtain the appropriate values from your `phpinfo()`. Then create and link or copy the files into place manually.

### Get installation parameters from phpinfo()

If this process doesn't work for you, you can get the correct information from your `phpinfo()` and pass the appropriate settings to your system as environment variables.

| phpinfo()   | Notes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PHPAPI`    | This is labeled `PHP Extension` in the `phpinfo()` header.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `ARCH`      | This can be determined by executing `file /path/to/php`. - If you see a reference to `ELF-32`, then the `ARCH` is `x86`. - If you see a reference to `ELF-64`, then the `ARCH` is `x64`.                                                                                                                                                                                                                                                                                                                               |
| `MODULEDIR` | This is labeled `extension_dir` in the PHP Core section.                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `PHPZTS`    | ZTS options apply only to [PHP agent versions 9.19.0.309 and earlier](https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/php-agent-9200310/). ZTS is not available for PHP agent versions 9.20.0.310 or higher. To determine whether ZTS is compiled in, look for the `Thread Safety` setting at the top of the `phpinfo()` output. - If this is disabled, then `PHPZTS` is empty. - If this is enabled, then `PHPZTS` is the string `-zts`, which includes a leading hyphen as noted. |
| `NRBASEDIR` | This is the base directory of the New Relic agent installation directory; for example, `/usr/lib/newrelic-php5` or the directory where you extracted the tar file for tarball installations.                                                                                                                                                                                                                                                                                                                           |

Use this information to execute the following commands to install the PHP module. Be sure to adjust the example's values to your actual settings.

```bash
NRBASEDIR=/usr/lib/newrelic-php5; export NRBASEDIR
    MODULEDIR=/usr/lib/php/modules; export MODULEDIR
    ARCH=x64; export ARCH
    PHPAPI=20090626; export PHPAPI
    PHPZTS="-zts"; export PHPZTS
    rm -f $MODULEDIR/newrelic.so
    ln -s $NRBASEDIR/agent/$ARCH/newrelic-${PHPAPI}${PHPZTS}.so \
      $MODULEDIR/newrelic.so
```

### Manual configuration

The next step is configuration.

1.  Copy the `$NRBASEDIR/scripts/newrelic.ini.template` to the directory from where your PHP installation reads additional config files and rename it `newrelic.ini`.

    To determine the destination, look at your `phpinfo()` output for the item, called `Scan this dir for additional .ini files`. If the directory listed is `(none)`, add settings from this file to your listed PHP config files (usually `php.ini`).
2.  Replace the license key setting in your `newrelic.ini` file with your license key. Also change any other sessions as needed (for example, `newrelic.appname`).
3.  Copy `$NRBASEDIR/daemon/newrelic-daemon.$architecture` to `/usr/bin/newrelic-daemon`.

    Depending on your system, $architecture will be either x86 or x64.
4.  Restart your dispatcher/web server.
5.  Verify that your site is functioning properly. If it isn't, remove `newrelic.ini` or the `newrelic.so` you created, and restart your dispatcher/web server again to restore the old operation.
6.  Examine your web server/dispatcher logfiles (**not** `newrelic`) to help determine the issue. If you still need assistance, get support at [support.newrelic.com](https://support.newrelic.com).

### Verify installation

Check that the agent is installed after the restart, by investigating the `phpinfo()` page for a `newrelic` section. If it appears the agent was successfully installed, check your system to verify that two `newrelic-daemon` processes are running:

-   For RedHat based systems:

    ```bash
    ps -aef | grep newrelic-daemon
    ```
-   For Debian based systems:

    ```bash
    ps aux | grep newrelic-daemon
    ```

Generate some traffic on your app, then wait for three to five minutes for results to arrive in your [APM **Summary** page](https://docs.newrelic.com/docs/apm/apm-ui-pages/monitoring/apm-summary-page-view-transaction-apdex-usage-data/).
