Relic Solution: Plesk and New Relic PHP Agent

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.

pleskinstallagent

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:

https://discuss.newrelic.com/t/relic-solution-using-abstract-sockets/56402

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:

cat /etc/psa/php_versions.json

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.

pleskperdirectory

4 Likes

If it does not work immediately, restart the PHP-FPM service in Plesk under Services.

1 Like

Hey @dirk-helbert - Sounds like you got this working for you and I appreciate you sharing the ProTip!

Setting the newrelic.appname=“example.org” in the Additional configuration directives does not seem to work and it just stays the default “PHP Application”.

Even phpinfo() for that domain still displays the default name.

It even appears in /var/www/vhosts/system/example.org/etc/php.ini as i configured it in additional directives, yet its overridden somewhere else?

PHP as FastCGI on Plesk Obsidian 18.0.46 on AlmaLinux 8.

How to actually set it?

UPDATE: If i comment out the newrelic.appname from the main newrelic.ini in for example /opt/plesk/php/7.4/etc/php.d/newrelic.ini, then the additional directive starts to work.