• Log in

Python agent and mod_wsgi web server

This documentation explains requirements and tips for integrating the Python agent with apps that use Apache/mod_wsgi or mod_wsgi-express. To return to the general install instructions, go to Install the for Python agent.

Use Apache/mod_wsgi

The Python agent supports the use of Apache/mod_wsgi. Follow the standard instructions for manual integration with your Python application when using Apache/mod_wsgi.

Caution

The recommended integration procedure of running the admin script via the command line 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.

Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.