In this tutorial, we'll show you how to install and configure New Relic for monitoring PHP apps. You need to follow this tutorial rather than the standard New Relic instructions because ServerPilot installs its own builds of PHP on your servers.
SSH in to your server as root and run the following commands:
wget -O - https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - sudo bash -c "echo deb http://apt.newrelic.com/debian/ newrelic non-free > /etc/apt/sources.list.d/newrelic.list" sudo apt-get update sudo apt-get install newrelic-php5
If you want New Relic available for PHP 5.4, 5.5, 5.6, and 7.0, repeat the following instructions for each version.
First, start the New Relic installer by running the following commands as root. IMPORTANT: Replace X.Y in all commands below with either 7.0, 5.6, 5.5, or 5.4.
sudo NR_INSTALL_PATH=/opt/sp/phpX.Y/bin newrelic-install
In the installer, choose #1 ("Install the New Relic Agent and Daemon").
Enter your New Relic license key when prompted.
The New Relic installer will create the file
This is where you can edit your New Relic license key, if required.
Finally, restart PHP with this command:
sudo service phpX.Y-fpm-sp restart
That's it. You can confirm that New Relic installed by looking for it in the
phpinfo() or with phpX.Y-sp -i at the
command line. For example:
$ php5.4-sp -i | grep newrelic newrelic newrelic.daemon.logfile => /var/log/newrelic/newrelic-daemon.log newrelic.daemon.ssl => enabled newrelic.logfile => /var/log/newrelic/php_agent.log newrelic.loglevel => no value ...
You can identify individual apps to New Relic by creating a .user.ini file in each app's web root directory (that is, create the file apps/APPNAME/public/.user.ini) with the contents:
newrelic.appname = "APPNAME"
This sets the name of the New Relic application that metrics will be reported into. This is how the name will be seen on the New Relic website.