Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Installing php agent on docker linux alpine

errors

#1

Hello, i am installing agent for php on docker with alpine linux
The version of agent i use is the latest newrelic-php5-8.3.0.226-linux-musl
The resulting error i am getting all the time is:

ERROR: the following directories could not be found:
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86
ERROR: the following files could not be found:
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20170718-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20170718.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20160303-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20160303.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20151012-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20151012.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20131226-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20131226.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20121212-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20121212.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20100525-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20100525.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20090626-zts.so
   /tmp/newrelic-php5-8.3.0.226-linux-musl/agent/x86/newrelic-20090626.so

The command inside dockerfile looks like this:

RUN export NEWRELIC_VERSION=$(curl -sS https://download.newrelic.com/php_agent/release/ | sed -n 's/.*>\(.*linux-musl\).tar.gz<.*/\1/p') && \
    curl -L "https://download.newrelic.com/php_agent/release/${NEWRELIC_VERSION}.tar.gz" | tar -C /tmp -zx && \
    NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install && \
      rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
      sed -i \
          -e "s/newrelic.license =.*/newrelic.license = ${NEW_RELIC_LICENSE_KEY}/" \
          -e "s/newrelic.appname =.*/newrelic.appname = ${NEW_RELIC_APP_NAME}/" \
          /etc/php7/conf.d/newrelic.ini

Also i tried to use NR_INSTALL_ARCH=x64 and it didn’t help at all.

Did anyone face that issue? Any ideas how to solve?


#2

The musl installer for Alpine does not come with files compiled for x86 because Alpine is 64bit only. The installer script detects the OS and skips the check for x86 files if the OS is Apline. You can see this check around line 270 here:

check_dir "${ilibdir}/agent/${arch}"
if [ -z "${ispkg}" ] && [ "${arch}" = "x64" ]; then
  # Only check for x86 directory on supported platforms.
  case "$ostype" in
    alpine|darwin|freebsd) ;;
    *) check_dir "${ilibdir}/agent/x86" ;;
  esac
fi

So it sounds like either the base image your dockerfile is using isn’t actually alpine or the installer can’t detect your OS. Can you share the FROM line from your dockerfile?


#3

@beastman Thank you for your response!
In my Dockerfile i have

FROM php:7.2-fpm-alpine3.7 AS base
..... and after for production environment
FROM base:latest AS build

After your idea was trying to find on dockerhub that image or in github, but no luck. So now i am worried :smiley:
Can you please advice what image to try instead?


#4

That image is from the official PHP repo but it looks like they’ve replaced it with alpine3.8:

https://hub.docker.com/r/_/php/

I tested that image with a quick and simple dockerfile:

FROM php:7.2-fpm-alpine3.7

RUN apk add curl bash

RUN \
 curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-8.3.0.226-linux-musl.tar.gz | tar -C /tmp -zx && \
   NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install

This installs the agent:

bash-4.4# /usr/local/sbin/php-fpm -m | grep newrelic
newrelic
bash-4.4# /usr/local/sbin/php-fpm -i | grep newrelic.ini
/usr/local/etc/php/conf.d/newrelic.ini

I did notice the config files for PHP are in a different spot than in your script, /usr/ instead of /etc/. So it could be something else being installed that is tripping up our installer and making it think it is not Alpine.


#5

Encountered the same issue. For me it was xdebug triggering the error.

Following dockerfile was triggering the error:

FROM base as php_builder
ARG PHP_LIB_PATH
ARG PHP_DBG_PATH
ARG PHP_CONF_D
ARG NEWRELIC_AGENT_VERSION

RUN apk --no-cache add curl

##XDEBUG
RUN echo “Xdebug installation”
RUN mkdir -p ${PHP_DBG_PATH}
RUN apk add --no-cache $PHPIZE_DEPS
RUN yes | pecl install xdebug
#&& apk del $PHPIZE_DEPS

#NEW RELIC
RUN echo “Installing Newrelic”

RUN
curl -L https://download.newrelic.com/php_agent/release/newrelic-php5-8.3.0.226-linux-musl.tar.gz | tar -C /tmp -zx &&
NR_INSTALL_USE_CP_NOT_LN=1 NR_INSTALL_SILENT=1 /tmp/newrelic-php5-*/newrelic-install install

However If i took out (or moved it to the end) xdebug block, everything worked as expected.


#6

Thanks for sharing your findings! While we do have some limitations capturing errors with XDebug enabled I hadn’t run into issues with it causing problems for the installer before.

https://docs.newrelic.com/docs/agents/php-agent/troubleshooting/php-agent-not-reporting-errors