2026年11月13日

2026年11月13日

Set Up New Relic APM for PHP and WordPress on Ubuntu

This article is a localized edition of the Japanese original. Read the Japanese original

New Relic APM (Application Performance Monitoring) is a service that records what takes time inside your application. For a PHP site, you can see response time per page, slow transactions, slow SQL, external API calls, PHP errors and more on its dashboards.

APM works by installing an "agent" for your application's language. This article uses a PHP application, including WordPress, running on Ubuntu as the example, and covers the PHP agent from installation to verification. The steps follow the official New Relic documentation as of November 2026, and we installed agent 12.12.0.41 on Ubuntu 24.04 with PHP 8.3 to confirm the file locations and that PHP loads it.

APM vs. the infrastructure agent

Type What you install What it shows
APM A language-specific agent (for PHP, the newrelic-php5 package) Time per page and per operation, slow SQL, external calls, application errors
Infrastructure The newrelic-infra package Server-wide state such as CPU, memory, disk, network and processes

newrelic-sysmond, which appears in older guides, is a legacy server-monitoring daemon, not an APM agent. To monitor the server itself, use the infrastructure agent described later. Also, newrelic-admin generate-config is a Python agent command and newrelic.yml is the configuration file for agents such as Ruby and Java; neither is used for PHP.

Pricing at a glance

As of November 2026, the official pricing page says the free plan includes up to 100 GB of data ingest per month and one full platform user. If you exceed 100 GB on the free plan, data ingest stops for that month and you lose access to the platform (access returns the next month or when you switch to a paid plan). Check paid plan terms on New Relic's pricing page.

Supported environments (as of November 2026)

  • PHP 7.2 to 8.5 (PHP 8.3 requires agent 10.15.0.4 or later). Thread-safe (ZTS) PHP builds are not supported.
  • Apache with mod_php, or any web server running PHP through PHP-FPM (FastCGI), such as Nginx
  • Installation with apt covers Ubuntu and Debian on x86_64. On ARM64 (aarch64) servers, you install from the tar file.
  • WordPress 6.0 and later is listed as a supported framework.

Step 1: Find your license key

The agent identifies your account with your New Relic license key (the key whose type is "INGEST - LICENSE" on the API keys screen). Log in to New Relic and find it under "API keys" in the user menu or in Administration. Note that a user key (User key) is something different.

The license key is a secret used to send data. Do not paste it into repositories or chats.

Step 2: Install the PHP agent

Register New Relic's apt repository and install the newrelic-php5 package (despite the 5 in its name, the package supports PHP 8.x).

# Register the signing key
wget -O- https://download.newrelic.com/NEWRELIC_APT_2DAD550E.public | sudo gpg --import --batch --no-default-keyring --keyring /usr/share/keyrings/download.newrelic.com-newrelic.gpg

# Add the repository
echo 'deb [signed-by=/usr/share/keyrings/download.newrelic.com-newrelic.gpg] http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list

# Install
sudo apt-get update
sudo apt-get install newrelic-php5

During installation, a screen asks for the application name and license key. The values you enter are written to the configuration file.

To install without the prompts (for example in a provisioning script), pass the values to debconf first.

echo newrelic-php5 newrelic-php5/application-name string "My WordPress" | sudo debconf-set-selections
echo newrelic-php5 newrelic-php5/license-key string "YOUR_LICENSE_KEY" | sudo debconf-set-selections
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install newrelic-php5

With Ubuntu's standard PHP, the agent is hooked into PHP automatically. If you installed PHP yourself and see "Please run newrelic-install as root to complete installation.", run sudo newrelic-install install.

Step 3: Check the configuration file

On Ubuntu 24.04 with PHP 8.3, the configuration file is created in the following location and linked from the conf.d directories of both PHP-FPM and the CLI.

File Contents
/etc/php/8.3/mods-available/newrelic.ini The agent's main configuration
/etc/php/8.3/fpm/conf.d/20-newrelic.ini A link to the file above (for PHP-FPM)
/etc/php/8.3/cli/conf.d/20-newrelic.ini A link to the file above (for the command line)
/var/log/newrelic/php_agent.log The agent log
/var/log/newrelic/newrelic-daemon.log The log of the daemon that sends data

Replace 8.3 with your PHP version. The two main settings are:

newrelic.license = "YOUR_LICENSE_KEY"
newrelic.appname = "My WordPress"

newrelic.appname is the application name shown in New Relic. The default is "PHP Application," so if you monitor several sites, give each one a recognizable name.

Step 4: Restart PHP to apply

Settings are loaded when PHP restarts. Run the command that matches your setup.

# With PHP-FPM (Nginx, or Apache + PHP-FPM)
sudo systemctl restart php8.3-fpm

# With Apache mod_php
sudo systemctl restart apache2

Check that PHP has loaded the agent like this:

php -m | grep newrelic
php-fpm8.3 -m | grep newrelic

If newrelic is printed, it is loaded.

Step 5: Check the dashboards

Once your site receives traffic, an application with the name you set in newrelic.appname appears in "APM & Services" in New Relic within a few minutes. No data is sent while there is no traffic, so open a few pages yourself when checking.

The main screens to look at are:

Screen What it shows
Summary Trends in response time, throughput and error rate
Transactions Time per operation (URL or controller). Sort by slowest to find the culprit
Databases Slow SQL and the tables involved
External services Time spent on calls outside the server, such as external APIs
Errors PHP errors and the transactions where they occurred

WordPress is detected automatically, and with the default setting (newrelic.framework.wordpress.hooks.options = "plugin_callbacks") the time spent in callbacks that plugins and themes register on hooks is also recorded. This helps you narrow down which plugin is causing slowness.

Troubleshooting

Symptom What to check
The application does not appear Whether newrelic is listed by php -m and php-fpm8.3 -m. Whether you restarted PHP-FPM (or Apache). Whether the site received any traffic
Listed by php -m but no data is sent Whether /var/log/newrelic/newrelic-daemon.log shows a wrong license key or connection errors. Whether outbound HTTPS from the server is allowed
The app name is still "PHP Application" Change newrelic.appname in newrelic.ini and restart PHP
Not loaded into the PHP you use Check whether a different PHP is in use, and run sudo newrelic-install install

Monitoring the whole server too (infrastructure agent)

Server state such as CPU, memory and disk is collected by the infrastructure agent. On Ubuntu 24.04 the steps are as follows (you can also use the guided install in the New Relic UI).

# Write the license key to the configuration file
echo "license_key: YOUR_LICENSE_KEY" | sudo tee -a /etc/newrelic-infra.yml

# Register the signing key and repository (noble is the code name of Ubuntu 24.04)
curl -fsSL https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/newrelic-infra.gpg
echo "deb https://download.newrelic.com/infrastructure_agent/linux/apt/ noble main" | sudo tee -a /etc/apt/sources.list.d/newrelic-infra.list

# Install and check the status
sudo apt-get update
sudo apt-get install newrelic-infra -y
sudo systemctl status newrelic-infra

On Ubuntu 22.04, change noble to jammy. Because /etc/newrelic-infra.yml contains the license key, it is safer to make it unreadable by other users.

For another service that monitors servers in a similar way, see also How to monitor a server with Datadog.

Summary

  • For PHP APM, install the newrelic-php5 package, set newrelic.license and newrelic.appname in newrelic.ini, and restart PHP-FPM or Apache.
  • Confirm loading with php -m | grep newrelic, generate some traffic, then check the app in "APM & Services."
  • Server metrics such as CPU and memory are collected not by APM but by the infrastructure agent (newrelic-infra).

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲