How to install New Relic PHP agent monitoring on DreamHost VPS (no root/sudo)

New Relic is a modern performance monitoring service capable of analyzing infrastructure and application. The PHP agent can be installed on DreamHost VPS without sudo and with a little bit of patience (just like New Relic’s server monitoring counterpart.)

Get the latest release of the New Relic PHP agent:

[VPS server]:~$ wget

Untar the tarball:

[VPS server]:~ $ tar xvfz newrelic-php5-*-linux.tar.gz

Note: If you have already setup New Relic server monitoring you can skip this part and go straight to editing the configuration.

Prepare your VPS user’s home to hold the PHP agent by creating directories for the configuration file, the binary and the logs:

[VPS server]:~$ mkdir -p bin var/log var/run etc

Copy the configuration template to your ~/etc/ directory:

[VPS server]:~$ cp newrelic-php5-*-linux/scripts/newrelic.cfg.template etc/newrelic.cfg

Edit ~/etc/newrelic.cfg to specify a custom path for the following keys:


Copy the 64-bit version of the daemon to the more comfortable ~/bin directory:

[VPS server]:~$ cp newrelic-php5- bin/newrelic-daemon

At this point you should be able to start the daemon

[VPS server]:~$ ./bin/newrelic-daemon -c etc/newrelic.cfg

Now it’s time to configure your phprc files for the version of PHP your application is using. If you have never created your phprc file, DreamHost Knowledge Base has a guide.

If your application is using PHP 5.6, edit .php/5.6/phprc and add:

extension = "/home/$YOUR_USER/newrelic-php5-"
newrelic.license = "$YOUR_LICENSE"
newrelic.logfile = "/home/$YOUR_USER/log/newrelic-php-agent.log"
newrelic.appname = "$YOUR_APP"
newrelic.daemon.logfile = "/home/$YOUR_USER/log/newrelic-daemon.log"
newrelic.daemon.port = "/home/$YOUR_USER/var/run/newrelic.sock"
newrelic.daemon.pidfile = "/home/$YOUR_USER/var/run/"
newrelic.daemon.location = "/home/$YOUR_USER/bin/newrelic-daemon"
newrelic.daemon.auditlog = "home/$YOUR_USER/log/newrelic-audit.log"

For PHP 7.0 the configuration is almost identical, except you need to change the newrelic extension. Edit .php/7.0/phprc

extension = "/home/$YOUR_USER/newrelic-php5-"

and the same content as the PHP 5.6 above.

For PHP 7.1 edit .php/7.1/phprc

extension = "/home/$YOUR_USER/newrelic-php5-"

and the same content as the PHP 5.6 above.

To check that things work correctly from the command line, interrogate php

php -i | grep newrelic

If that comman outputs something, you can try executing a php command:

php  -r 'echo "Hello NewRelic!";'

Check the logs on ~/var/log and that there are pid and sock file on ~/var/run. If everything is configured correctly, you should see some reporting coming into your New Relic APM dashboard.

Things to be aware of

  1. If the VPS is restarted, you have to manually restart New Relic monitor.
  2. When New Relic releases a new version of its tools, you’ll have to manually update the software
  3. DreamHost has no official relationship with New Relic. This howto was produced for education only and is not an officially supported document. In fact, this post is a wiki: if you have suggestions, please edit it (or leave comments if your trust level is not high enough yet.)
1 Like