Configure New Relic for Magento 2 Project to monitor your store performance efficiently.
Therefore, you can track every request, optimize transactions, and prevent slowdowns before they affect users.
Moreover, this setup provides clear insights into your Magento store without mixing data from other applications.
Why Use New Relic with Magento 2
New Relic analyzes slow queries, server metrics, and transaction traces.
In addition, it identifies performance bottlenecks before they impact customers.
Project-specific configuration ensures only your Magento store is monitored.
As a result, you get accurate and actionable performance data.
Step 1: Installing the New Relic PHP Agent
To begin, install the New Relic PHP agent on your server.
First, select the installation method that matches your operating system.
Installation on Ubuntu/Debian
echo "deb http://apt.newrelic.com/debian/ newrelic non-free" | sudo tee /etc/apt/sources.list.d/newrelic.list wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add - sudo apt-get update sudo apt-get install newrelic-php5 sudo newrelic-install install
Installation on CentOS/RHEL
sudo rpm -Uvh https://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm sudo yum install newrelic-php5 sudo newrelic-install install
During installation, the installer prompts you to enter your New Relic license key.
Consequently, the agent activates and begins monitoring your application.
Step 2: Verifying the Installation
php -i | grep "newrelic"
You should see something like this:
$ php -i | grep "newrelic" /etc/php/8.2/cli/conf.d/20-newrelic.ini, newrelic newrelic.daemon.address => @newrelic newrelic.daemon.app_connect_timeout => no value newrelic.daemon.app_timeout => no value newrelic.daemon.auditlog => no value newrelic.daemon.collector_host => no value newrelic.daemon.dont_launch => no value newrelic.daemon.location => /usr/bin/newrelic-daemon newrelic.daemon.logfile => /var/log/newrelic/newrelic-daemon.log newrelic.daemon.loglevel => no value newrelic.appname => PHP Application => PHP Application newrelic.daemon.pidfile => no value
Next, restart PHP-FPM or Apache to apply the changes:
sudo service php7.4-fpm restart sudo service nginx restart # OR for Apache sudo service apache2 restart
At this stage, You may see a generic app name eg: “PHP Application” in APM.

However, this can be customized for your Magento project.
Step 3: Configuring New Relic for Your Magento Project
Edit pub/index.php to configure New Relic.
This way, New Relic groups all requests under your project name.
Example code:
// Configure New Relic for this Magento application
if (extension_loaded('newrelic')) {
newrelic_set_appname('CustomProject-Magento');
}
As a result, New Relic tracks only your Magento project.
Therefore, data from other PHP applications does not mix in.

Benefits of Project-Level Configuration
Setting the application name scopes transactions to your store.
Furthermore, it improves performance analysis and troubleshooting.
Moreover, combining this setup with tools like Redis for Magento 2 session management further optimizes site speed.
Monitoring and Insights
Once configured, log in to New Relic to view APM data.
You will see transactions, response times, database queries, and slow traces specific to your Magento project.
Project-level monitoring allows you to make informed decisions to improve site speed and reliability.
Conclusion
Installing and configuring New Relic for Magento 2 allows detailed application-level monitoring.
Furthermore, by setting the application name in index.php, your store is tracked independently from other server applications.
This approach keeps monitoring simple, clean, and effective.
Pairing New Relic with caching solutions like Redis enhances Magento’s scalability and performance.

Be the first to comment.