Skip to content

Instantly share code, notes, and snippets.

@avramovic
Created May 18, 2022 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save avramovic/14df79f170caf69261faa671413337c6 to your computer and use it in GitHub Desktop.
Save avramovic/14df79f170caf69261faa671413337c6 to your computer and use it in GitHub Desktop.
New Relic PHP agent (v9.21) on AWS Elastic Beanstalk AMI Linux 2 (arm based cpu)
files:
"/etc/httpd/conf.modules.d/11-mpm.conf":
mode: "000755"
owner: root
group: root
content: |
LoadModule mpm_event_module modules/mod_mpm_event.so
"/etc/php.d/20-newrelic.ini":
mode: "000755"
owner: root
group: root
content: |
extension = "newrelic.so"
[newrelic]
newrelic.license = "YOUR_NEW_RELIC_LICENSE_KEY_HERE"
newrelic.logfile = "/var/log/newrelic/php-agent.log"
newrelic.appname = "YOUR_APP_NAME"
newrelic.daemon.logfile = "/var/log/newrelic/newrelic-daemon.log"
"/home/ec2-user/newrelic-setup.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
if [[ -f "/usr/bin/newrelic-daemon" ]]; then
echo "Skipping NewRelic installation as binary /usr/bin/newrelic-daemon already exists."
exit 0;
fi
yum install -y make glibc-devel gcc gcc-c++ patch golang php-devel bzip2 libcurl \
libedit libjpeg libmcrypt libpng readline-devel libtidy libtool libxml2 libxslt \
openssl pcre zlib pcre-devel
# download and unpack new relic
curl https://github.com/newrelic/newrelic-php-agent/archive/refs/tags/v9.21.tar.gz --output /tmp/newrelic.tar.gz -L
cd /tmp
tar -xvf newrelic.tar.gz
# compile new relic
cd newrelic-php-agent-9.21
make
cp bin/daemon /usr/bin/newrelic-daemon
# make log folder for new relic
mkdir /var/log/newrelic/
# install new relic agent in php
make agent-install
# restart services
/usr/bin/systemctl restart httpd.service
/usr/bin/systemctl restart php-fpm.service
# cleanup
rm -rf /tmp/newrelic-php-agent-9.21
rm -rf /tmp/newrelic.tar.gz
container_commands:
install_newrelic:
command: /home/ec2-user/newrelic-setup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment