Plesk has a New Relic extension that lets you install the New Relic PHP Agent from the Plesk control panel. Here is how it works!
Install the Plesk Extension
Under Extensions on the left, go to the “Monitoring” section and you’ll see the New Relic APM extension. Click to install this Plesk extension. Note that this only installs the Plesk extension, it does not yet do anything with New Relic.
Install New Relic from the New Relic Plesk Extension
Click Extensions on the left again and go to “My Extensions” and you should now see the New Relic extension. Click “go to extension” to get to the New Relic configuration and install page.
The license key will be supplied to the newrelic-install script. The accountID is needed to create a handy link to your New Relic account page.
You can also choose to install the PHP agent for only specific versions of PHP or for all versions. If you later add a new version of PHP you’ll need to come back to this page and reinstall.
Set the New Relic App Name
The New Relic App Name is set by default in the newrelic.ini. The server default will be in /etc/php.d/newrelic.ini but other versions of PHP will use a path like /opt/plesk/php/7.2/etc/php.d/newrelic.ini
To set the global appname for all versions of PHP you can use the following commands:
sed -i -e "s/newrelic.appname =.*/newrelic.appname = My Unique Name/" /opt/plesk/php/*/etc/php.d/newrelic.ini sed -i -e "s/newrelic.appname =.*/newrelic.appname = My Unique Name/" /etc/php.d/newrelic.ini
If you are using CentOS you or other SELinux systems you may need to switch to an abstract socket as documented here:
To set the abstract port for all versions of PHP:
sed -i -e "s/;newrelic.daemon.port =.*/newrelic.daemon.port = "@newrelic-daemon"/" /opt/plesk/php/*/etc/php.d/newrelic.ini sed -i -e "s/;newrelic.daemon.port =.*/newrelic.daemon.port = "@newrelic-daemon"/" /etc/php.d/newrelic.ini
To check where all the PHP installs are located:
Which looks like this:
"id":"plesk-php56-fpm", "path":"/opt/plesk/php/5.6/sbin/php-fpm", "clipath":"/opt/plesk/php/5.6/bin/php", "phpini":"/opt/plesk/php/5.6/etc/php.ini", "version":"5.6.33", "displayname":"%24version", "type":"fpm", "system":true, "service":"plesk-php56-fpm", "poold":"/opt/plesk/php/5.6/etc/php-fpm.d"
Set per-domain app names
Plesk allows you to set numerous options from the UI, including per-directory PHP settings like the newrelic.appname. You can set them by going to the domain’s PHP settings and adding newrelic.appname = “myapp” to the “Additional Configuration directives” section.