Why and when to restart your web server (PHP)

Problem

You are unsure why or when you must restart your web server (Apache, PHP-FPM, Nginx, etc.) after:

Cause

The PHP agent is a PHP extension. When your web server starts up and loads PHP, it also loads the PHP agent and parses its newrelic.ini configuration file. The web server uses that configuration until told to re-load and parse configuration files again. Restarting prompts the web server to do that.

You must restart your web server when:

You modify your configuration file.

Configuration changes in newrelic.ini or newrelic.cfg files do not take effect (for example, naming your app, generating logs, changing your license key) until you restart the web server.

Your package manager auto-updates the agent without restarting the web server.

To avoid this situation, set an exclude for newrelic-php5* in your package manager.

If your package manager automatically updates the agent, you must restart your web server. Updating the agent without restarting can cause the agent to stop reporting.

This issue occurs when auto-update is enabled and the daemon updates to a new version. The new daemon is then unable to communicate with the agent, which is still running the old version.

To avoid this, the new agent must be started after the update. This process is complicated, because a full agent restart also requires you to restart your web server software.

The daemon is set to start up in external mode.

If you have the agent in external startup mode, you must manually start the daemon and restart the agent for the agent to report.

Apache isn't fully restarting with the apachectl restart command.

Using the apachectl restart command does not always fully restart the web server, so it doesn't re-parse the agent's configuration files. New Relic recommends using:

apachectl stop
apachectl start

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.