Skip to content

Instantly share code, notes, and snippets.

@n-my
Last active February 3, 2017 17:06
Show Gist options
  • Select an option

  • Save n-my/5373c74fc9725037376d3416c791c7c5 to your computer and use it in GitHub Desktop.

Select an option

Save n-my/5373c74fc9725037376d3416c791c7c5 to your computer and use it in GitHub Desktop.
Install the New Relic PHP agent with Packer and Terraform via the user data
### Packer
# Install New Relic
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list
apt-get install -y ca-certificates
wget -q -O /tmp/548C16BF.gpg https://download.newrelic.com/548C16BF.gpg
apt-key add /tmp/548C16BF.gpg
apt-get update -q
echo newrelic-php5 newrelic-php5/application-name string "__NEW_RELIC_APP_NAME__" | debconf-set-selections
echo newrelic-php5 newrelic-php5/license-key string "__NEW_RELIC_LICENSE__" | debconf-set-selections
apt-get install -y newrelic-php5
### Terraform
# Set the New Relic license
sed -i.bak "s#__NEW_RELIC_APP_NAME__#$${new_relic_app_name}_$${app}_${stack}#" /etc/php/*/mods-available/newrelic.ini
sed -i.bak "s#__NEW_RELIC_LICENSE__#$${NEW_RELIC_LICENSE}#" /etc/php/*/mods-available/newrelic.ini
# Restart php-fpm for new relic
/etc/init.d/php*-fpm restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment