PHP installation fails on OS X 10.11 - El Capitan

Problem

You attempt to install the PHP agent on OS X 10.11 - El Capitan, and it fails.

Failure with the install script

Using the script newrelic-install you encounter something similar to this:

   Install daemon ([y]es, [n]o or x to e[x]it): y

FATAL: failed to copy new daemon into place
FATAL: New Relic agent installation failed.

       Please contact http://support.newrelic.com
       and report the above error. We have also created a tar file with
       log files and other system info that can help solve the problem.
Failure with the manual install process

Using the manual install process with the install utility nrmaninstall.php, or following the manual instructions, you encounter something similar to this:

$ sudo cp ./agent/x86_64/newrelic-20121212.so /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/newrelic-20121212.so: Operation not permitted

$ sudo cp ./daemon/newrelic-daemon.x86_64 /usr/bin/newrelic-daemon
cp: /usr/bin/newrelic-daemon: Operation not permitted

Solution

The PHP agent may be installed by disabling (SIP). This is true for both the newrelic-install script and manual installations.

This is not an endorsement for disabling SIP in general and you are advised to verify that this does not violate the security policies of your organization.

The general procedure is:

  1. Boot into recovery mode
  2. Disable SIP and reboot
  3. Install the New Relic PHP agent
  4. Boot into recovery mode
  5. Re-enable SIP and reboot

There are many articles available on the web that describe SIP and the steps for disabling, re-enabling, and checking the status.

Cause

The installation of the PHP agent requires that the daemon program be installed in /usr/bin and the extension module in /usr/lib. However, those directories have R-X permissions, which means the daemon cannot be installed by normal means.

Apple's new System Integrity Protection, SIP, prevents the modification of permissions on these directories even when logged in as root, admin or via a sudo privileged account. This also applies in situations where the PHP bin is self contained (For example, MAMP).

For more help

Additional documentation resources include PHP Agent Troubleshooting (individual topics describing common problems, causes, and solutions for your PHP agent installation).

Join the discussion about PHP in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.