Install the New Relic PHP Agent
The New Relic PHP agent includes a PHP extension that collects data from your application and a local proxy daemon that transmits this data to New Relic.
The installation process varies depending on your system's configuration, including your web server, operating system, system permissions, PHP installation, and package manager. This guide provides basic step-by-step instructions for installing the PHP agent on different operating systems.
Installing PHP via Partnership Accounts
Installation procedures may differ for administrators installing the PHP agent via a partnership account. Not all partners support PHP agents. For more information on specific partners, refer to the following:
- AWS
- Heroku
- Magento
- Shared Hosting Providers
- Other Partnership Installation Procedures
Prerequisites
Before you begin the installation process:
- Ensure your system meets the agent's requirements, including appropriate system permissions
- If you do not have a New Relic account, create one
- Copy your license key from your New Relic Account settings
Install the Agent
Follow these steps to install the PHP agent on your system. The agent installation package or tar archive includes the newrelic-install script, which automates some of the installation tasks.
Step 1: Ensure Prerequisites Are Met
Verify all system requirements and prerequisites listed above.
Step 2: Obtain the Installation Package
Depending on your operating system, download the appropriate installation package or tar archive:
RedHat or CentOS
The preferred method for installing the agent on RedHat or CentOS is through the .rpm package using your package manager (yum or rpm). You can configure the package manager to retrieve it from the New Relic repository, or download the .rpm file directly from the New Relic website.
Ubuntu or Debian
For Ubuntu or Debian, the agent is typically installed using the .deb package via apt-get or dpkg. Configure the repository, then either use apt-get to install or manually download and run the package manager on the .deb files.
Tar Archive Method
The tar archive method is the most generic and can be used on all supported operating systems. This method is ideal if:
- Your operating system is not listed
- You are not using a package manager
- Other methods have been unsuccessful
Step 3: Install the Agent Package or Tar Archive
Important
The specific installation commands vary by platform. See the platform-specific guides for detailed instructions.
RedHat or CentOS
Install the package using yum or rpm, then run the newrelic-install script.
# Using yum
sudo yum install newrelic-php5
# Then run the install script
sudo newrelic-install install
For more detailed instructions, see Install PHP on RedHat or CentOS.
Ubuntu or Debian
Install the package using apt-get or dpkg. Running the newrelic-install script is typically unnecessary.
# Using apt-get
sudo apt-get install newrelic-php5
# The installation script typically runs automatically
For more detailed instructions, see Install PHP on Ubuntu or Debian.
Tar Archive Method
Extract and install the tar archive on any supported platform.
# Extract the tar archive
tar -xzf newrelic-php5-*.tar.gz
# Navigate to the extracted directory
cd newrelic-php5-\*
# Run the installation script
sudo ./newrelic-install install
For more detailed instructions, see Install PHP manually with tar archive.
Step 4: Configure the Agent
After installation, configure the agent for your application:
- Change the default application name to a meaningful name
- Optionally, modify other agent configuration settings to further customize your installation
# Edit the newrelic.ini file
sudo nano /etc/php5/conf.d/newrelic.ini
# Set your application name
newrelic.appname = "Your Application Name"
# Add your license key
newrelic.license = "YOUR_LICENSE_KEY"
Step 5: Restart Your Web Server
Restart the relevant web server for the changes to take effect:
# For Apache
sudo service apache2 restart
# For Nginx with PHP-FPM
sudo service php-fpm restart sudo service nginx restart
# For other services
sudo service [service-name] restart
Step 6: Verify Installation
Wait a few minutes for your application to send data to New Relic. You can verify the installation by:
- Checking your New Relic dashboard for incoming data
- Running
php -m | grep newrelicto confirm the extension is loaded - Checking PHP info page for New Relic section
Tip
If data doesn't appear after 5 minutes, check the agent log files at
/var/log/newrelic/ for troubleshooting information.
For More Help
Additional documentation resources include:
- New Relic for PHP - Overview of agent functionality, requirements, and installation
- Upgrading the PHP agent - Steps for upgrading the agent by platform
- Uninstalling the PHP agent - Steps for uninstalling the agent by platform
- The newrelic-install script - Steps for using the install script to install and uninstall the agent
- Installing with specific platforms:
- RedHat and CentOS - Detailed, system-specific installation instructions
- Ubuntu and Debian - Platform-specific guide
- Tar archive - Manual installation process
- Non-standard PHP - Detailed information on troubleshooting the newrelic-install script and performing a manual installation