Python agent and mod_wsgi

This doc provides some information on integrating the New Relic Python agent into your application if you are using Apache/mod_wsgi or mod_wsgi-express.

Use Apache/mod_wsgi

The New Relic Python agent can be used with Apache/mod_wsgi. There are no special requirements or restrictions.

Follow the standard instructions for manual integration with your Python application when using Apache/mod_wsgi.

The wrapper script cannot be used with Apache/mod_wsgi.

Use mod_wsgi-express

A new feature, called mod_wsgi-express, was introduced in version 4.1.0 of mod_wsgi, and it offers an alternate way to integrate the agent.

If you are using mod_wsgi-express with a WSGI application, it is possible to use the script's --with-newrelic option with your app's startup command. Although the mod_wsgi-express script and --with-newrelic flag are different than the newrelic-admin script, they serve the same purpose of configuring your application to wrap the execution of your server.

When using the --with-newrelic option, make sure the Python agent is installed and you've created your newrelic.ini config file.

For example, using the agent with Django may require a command similar to:

NEW_RELIC_CONFIG_FILE=newrelic.ini mod_wsgi-express start-server mysite/wsgi.py --with-newrelic

For more help

For more details, contact the Apache/mod_wsgi author on the mod_wsgi mailing list.

Join the discussion about Python 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.