• /
  • EnglishEspañol日本語한국어Português
  • Inicia sesiónComenzar ahora

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).

Importante

As part of the installation process, change the default application name to a meaningful name.

Requirements

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. ZTS is not available for PHP versions 9.18 or higher.

Use the command line newrelic-install script (recommended)

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

  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.

Install New Relic manually

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. 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. 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 . 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.

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.

¿Te ha ayudado este documento con la instalación?

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.