Install the New Relic PHP Agent on RedHat or CentOS
This guide details the steps required to install the New Relic PHP agent on RedHat or CentOS systems. It includes obtaining the installation package, installing the agent, and performing necessary configurations.
Tip
For instructions on installing the New Relic Infrastructure to monitor RedHat or CentOS operating systems, see New Relic Infrastructure for Linux.
Get the Installation Package
There are two primary methods to obtain the New Relic PHP agent installation package.
Configure the New Relic Repository
To tell the package manager about the New Relic repository, run the appropriate command for your system architecture:
For 32-bit systems:
sudo rpm -Uvh
http://yum.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
For 64-bit systems:
sudo rpm -Uvh
http://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm
Download the RPM Files Directly
If you prefer to download the files directly from the New Relic website, use the following links according to your system architecture. Substitute the X.X.X.X with the relevant version number.
For 32-bit systems:
Download the following packages:
newrelic-php5-common-X.X.X.X-1.noarch.rpmnewrelic-daemon-X.X.X.X-1.i386.rpmnewrelic-php5-X.X.X.X-1.i386.rpm
For 64-bit systems:
Download the following packages:
newrelic-php5-common-X.X.X.X-1.noarch.rpmnewrelic-daemon-X.X.X.X-1.x86_64.rpmnewrelic-php5-X.X.X.X-1.x86_64.rpm
Install the Agent
Tip
These commands apply only to first-time installations. If you have an earlier version of New Relic installed, see Upgrading the agent.
After obtaining the installation package, install the agent using your package manager and the install script:
Step 1: Install the agent and daemon
Install using your preferred package manager:
Using yum (Recommended)
>sudo yum install newrelic-php5
Important
The first time you install New Relic for PHP, yum prompts you to accept the
New Relic public key. New Relic's key ID is 548C16BF.
Using rpm for 32-bit systems
rpm -i newrelic-php5-common-X.X.X.X-1.noarch.rpm \
newrelic-daemon-X.X.X.X-1.i386.rpm \ newrelic-php5-X.X.X.X-1.i386.rpm
Using rpm for 64-bit systems
rpm -i newrelic-php5-common-X.X.X.X-1.noarch.rpm \
newrelic-daemon-X.X.X.X-1.x86_64.rpm \ newrelic-php5-X.X.X.X-1.x86_64.rpm
Using tarball
If yum and rpm do not work with your server configuration, install from the binary tarball:
# Download the tarball
wget https://download.newrelic.com/php_agent/release/newrelic-php5-X.X.X.X-linux.tar.gz
# Extract the archive
tar -xzf newrelic-php5-X.X.X.X-linux.tar.gz
# Navigate to the directory
cd newrelic-php5-X.X.X.X-linux
# Run the install script
sudo ./newrelic-install install
Step 2: Configure the Agent
After installation, run the New Relic install script to configure your installation:
>sudo newrelic-install install
The script will prompt you for:
- Your New Relic license key
- Your application name
You can also manually edit the configuration file:
# Edit the configuration file
sudo nano /etc/php.d/newrelic.ini
# Key configuration options:
newrelic.license = "YOUR_LICENSE_KEY" newrelic.appname = "Your Application Name"
Step 3: Restart Your Web Server
Restart your web server for the changes to take effect:
# For Apache (httpd)
sudo service httpd restart
# Or on newer systems
sudo systemctl restart httpd
# For Nginx with PHP-FPM
sudo service php-fpm restart sudo service nginx restart
# Or on newer systems
sudo systemctl restart php-fpm sudo systemctl restart nginx
Step 4: Verify Installation
Wait a few minutes for your application to send data to New Relic. You can verify the installation:
# Check if the New Relic module is loaded
php -m | grep newrelic
# Check the daemon status
sudo service newrelic-daemon status
# Or on newer systems
sudo systemctl status newrelic-daemon
# View agent logs for troubleshooting
tail -f /var/log/newrelic/newrelic-daemon.log tail -f /var/log/newrelic/php_agent.log
Important
If you don't see data in your New Relic dashboard after 5 minutes: 1. Verify your license key is correct 2. Check that the daemon is running 3. Ensure your application is receiving traffic 4. Review the log files for errors
Troubleshooting Common Issues
SELinux Conflicts
If SELinux is enabled, you may need to adjust policies:
# Check SELinux status
sestatus
# If needed, set SELinux to permissive mode temporarily
sudo setenforce 0
# Or create a policy for New Relic
sudo setsebool -P httpd_can_network_connect 1
Firewall Configuration
Ensure your firewall allows outbound HTTPS connections to New Relic:
# Check firewall status
sudo firewall-cmd --state
# Allow outbound HTTPS if needed
sudo firewall-cmd --zone=public --add-service=https --permanent sudo firewall-cmd --reload
For More Help
Additional documentation resources include:
- New Relic for PHP - Compatibility and requirements, license key information
- PHP agent installation: non-standard PHP - Installing on a non-standard PHP configuration
- Main Installation Guide - Return to the general installation overview
- PHP Agent Attributes - Configure agent attributes and data collection