Relic Solution: PHP Agent Not Reporting Web Data

Note: in version of the PHP Agent, a new option for changing the daemon socket was added: newrelic.daemon.address. This document references newrelic.daemon.port, but if you are on a release >= v9.2.0.247, we recommend using newrelic.daemon.address instead.

You’ve just installed the New Relic PHP Agent and you can see the daemon process running and your application shows up as green in your APM dashboard but…there is no data. What’s the problem?

This guide will help you troubleshoot the issue of data not reporting for a new PHP Agent installation. While we can’t cover every possibility the following steps include common issues.

Why does this happen?

Systems can often have multiple versions of PHP installed, sometimes even multiple copies of the same version of PHP! For instance, you might have some applications using PHP 7 while an older application might still be using PHP 5. Our installer attempts to automatically detect where and how these PHP versions are installed and then to apply the correct version of the New Relic PHP extension to each of them. PHP configurations can vary wildly and other factors can cause them to be different than expected.

Often your command line PHP installation will be simply configured and the New Relic installer will have no trouble finding and installing the New Relic extension. So when you type in php -i on the command line the agent starts reporting and your chosen application name appears in the APM dashboard. But the web traffic can run into different PHP configurations as well as permission and security issues your command line doesn’t have.

How do we troubleshoot this?

Because the web server might be using a different PHP installation than the command line, we can’t rely on the output of php -i to give us correct information for troubleshooting the web traffic. So our first step is to create a phpinfo() page, ideally in the same directory as the web application so that it shows us the same PHP settings than the application is using. You can find more details about phpinfo() here:

Scroll down through your phpinfo page and you should see the New Relic extension loaded with all the New Relic settings including your application name as it will appear in APM.

But wait, New Relic isn’t showing up in my phpinfo page!

This means either the installer didn’t find your web server’s PHP or some configuration issue is causing it to not load. The Additional .ini files parsed section should have the newrelic.ini listed. This contains all the New Relic settings as well as the line to load the New Relic extension. If this .ini file isn’t listed then the this PHP installation doesn’t have New Relic installed. In this case you should run the installer again and select the correct PHP installation when prompted.

If the newrelic.ini is being loaded then PHP is being told to load the New Relic extension but isn’t for some reason. This will depend on the extension_dir which will be listed in your phpinfo page as well. The needs to be present in this extension directory. If it is not present, we’ll need to manually copy the correct version of the to this directory. If it is present there is likely an error in the PHP “error_log” detailing why it cannot load the The error log might also be different than expected so check your phpinfo page for the location used by your web server.

Manually installing the New Relic extension

Even if it is present in the correct PHP extension directory, the errors might indicate it is compiled for a different version of PHP or some other error that requires you to replace it. First, download the installer for your OS here:

This contains all the versions of the New Relic PHP extension. To find what version is required for your PHP installation, check back on the phpinfo page for the PHP Extension build number. For instance, the PHP 5.4 extension build is 20100525. Also check if Thread Safety is enabled.

With the extension build number and the thread safety known, find the correct for your version and OS architecture in the installer directory under the “agent” directory, agent/xXX/ For instance, if you have a 64bit machine with PHP 5.4 and Thread Safety enabled, the correct file would be agent/x64/ Copy the correct file to your extension directory and name the file Restart your PHP handler to pick up the change and attempt to load the new extension.

The New Relic PHP extension is loaded and appears in my phpinfo page but still no data!

If the New Relic PHP extension is showing up in your phpinfo page and the application name is correct then the issue is usually with the agent communicating to the daemon process. This is a bit more complicated than the command line due to security settings on web servers so often the application will appear in APM from command line PHP calls but the web server traffic will not be reported.

In this case, check the New Relic agent logs located by default in /var/log/newrelic/php_agent.log. If data is not reporting generally you will see a daemon connect error such as the following example:

2017-11-21 11:56:14.596 -0800 (11576 11576) warning: daemon connect(fd=5 uds=/tmp/.newrelic.sock) returned -1 errno=ECONNREFUSED. Failed to connect to the newrelic-daemon.

In this case, the daemon is using the default socket file, /tmp/.newrelic.sock. On some systems the web server is not allowed to connect to sockets by default due to security settings. Without making security changes to allow it, on Linux systems you have the option of using an abstract socket which gets around filesystem permissions. To do this, edit your newrelic.ini and change the following:

;newrelic.daemon.port = "/tmp/.newrelic.sock"

To this:

newrelic.daemon.port = "@newrelic-daemon"

After making the change, kill any newrelic-daemon processes that are running and restart the PHP handler to pick up the change. More details on port options can be found here:

If you’re having trouble getting your agent to report data, you may want to try to New Relic Diagnostics tool. For our PHP Agent, it will double check if the daemon is running properly. We’ll be adding more checks to it as time goes on!

To use New Relic Diagnostics for this Support ticket, please download a copy. Here are more details on downloading and running this diagnostics tool.