Install New Relic PHP agent on Trellis servers.
# group_vars/<environment>/vault.yml
# This file should be encrypted. See: https://roots.io/trellis/docs/vault/
##########################################################################
# New Relic License Key
## See: https://docs.newrelic.com/docs/accounts-partnerships/accounts/account-setup/license-key
vault_newrelic_license: xxxxxxxxxxx
# group_vars/<environment>/main.yml
###################################
# Indicates the desired package state.
# `latest` ensures that the latest version is installed.
# `present` does not update if already installed.
# Choices: present|latest
# Default: latest
newrelic_package_state: present
# Check for default values here: https://github.com/TypistTech/trellis-newrelic-php/blob/master/defaults/main.yml
# See also: https://docs.newrelic.com/docs/agents/php-agent/configuration/php-agent-configuration
newrelic_config:
appname: "My Awesome App {{ env }}"
framework: no_framework
transaction_tracer.detail: 1
datastore_tracer.database_name_reporting.enabled: true
Add this role to dev.yml
and server.yml
immediately after role: php
:
# `dev.yml` & `server.yml`
roles:
# Some other Trellis roles ...
- { role: php, tags: [php] }
+ - { role: TypistTech.trellis-newrelic-php, tags: [php, newrelic-php] }
# Some other Trellis roles ...
Add this role to galaxy.yml
:
- src: TypistTech.trellis-newrelic-php # Case-sensitive!
version: XXX.YYY.ZZZ # Check for latest version!
Run $ trellis galaxy install
to install this new role.
Encrypt your New Relic license key in group_vars/<environment>/vault.yml
. See role variables.
Solution: Define different appname
for different environments.
Tips:
# group_vars/all/main.yml
#########################
newrelic_config:
appname: "My Awesome App {{ env }}"
New Relic would fail and causes provision end up in errors when upgrading PHP major or minor releases (e.g: from 7.4 to 8.0, from 8.0 to 8.1).
non-zero return code
PHP Warning: PHP Startup: Unable to load dynamic library 'newrelic.so'
(tried: /usr/lib/php/20180731/newrelic.so (/usr/lib/php/20180731/newrelic.so:
cannot open shared object file: No such file or directory),
/usr/lib/php/20180731/newrelic.so.so (/usr/lib/php/20180731/newrelic.so.so:
cannot open shared object file: No such file or directory)) in Unknown on
After each PHP major or minor release upgrade (i.e: when you see the above error):
# For multi-server setups, perform the following steps on each server.
ssh admin@123.456.789
sudo newrelic-install install
sudo reboot
# Wait for the server(s) to reboot and then re-provision
# For multi-server setups, you only need to re-provision once only
trellis provision production
- Only one New Relic APM application per server by default.
Extends
the fastcgi_basic
block to include fastcgi_param PHP_VALUE "newrelic.appname={{ item.key }} ({{ env }})";
right after the line include fastcgi_params;
to work around this limitation.
Pull requests are welcomed.
- Articles on Typist Tech's blog
- Tang Rufus' WordPress plugins on wp.org
- More projects on Typist Tech's GitHub profile
- Stay tuned on Typist Tech's newsletter
- Follow Tang Rufus' Twitter account
- Hire Tang Rufus to build your next awesome site
Thanks! Glad you like it. It's important to let me know somebody is using this project. Since this is not hosted on wordpress.org, please consider:
- ❤️ sponsor this project
- ⭐ star this Github repo
- 👀 watch this Github repo
- tweet something good with mentioning @TangRufus
- write blog posts
- submit pull requests
- hire me
Love trellis-newrelic-php
? Help me maintain it, a sponsorship here can help with it.
Do you know GitHub is going to match your sponsorship?
Sponsor now via GitHub to double your greatness.
Ready to take freelance WordPress jobs. Contact me via the contact form here or, via email info@typist.tech
Contact: Tang Rufus
Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.
If you discover any security related issues, please email trellis-newrelic-php@typist.tech instead of using the issue tracker.
Trellis New Relic PHP Agent is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.
Full list of contributors can be found here.
Special thanks to the Roots team whose Trellis make this project possible.
Please see CODE_OF_CONDUCT for details.
Trellis New Relic PHP Agent is released under the MIT License.