Tomas
Tomas

Reputation: 59

docker php8.0-apache new relic - Unable to load dynamic library 'newrelic.so'

I'm trying to run new relic in docker with php8.0-apache image.

I follow instruction by:

https://docs.newrelic.com/docs/agents/php-agent/advanced-installation/docker-other-container-environments-install-php-agent/

When I start container and see PHP warning

Warning: PHP Startup: Unable to load dynamic library 'newrelic.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/newrelic.so (/usr/local/lib/php/extensions/no-debug-non-zts-20200930/newrelic.so: cannot open shared object file: No such file or directory), /usr/local/lib/php/extensions/no-debug-non-zts-20200930/newrelic.so.so (/usr/local/lib/php/extensions/no-debug-non-zts-20200930/newrelic.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Dockerfile:

FROM php:8.0-apache

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

RUN sed -i \
      -e 's/"REPLACE_WITH_REAL_KEY"/"COMPANY-KEY"/' \
      -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "company-test"/' \
      -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
      -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
      /usr/local/etc/php/conf.d/newrelic.ini

Thank you for any help.

Upvotes: 2

Views: 1901

Answers (2)

Rakesh B E
Rakesh B E

Reputation: 892

check if there is any newrelic.ini file and remove it.

navigate to /etc/php5/cli/conf.d/ and delete all corresponding *.ini files.

This should resolve your problem.

Upvotes: 3

emptyhua
emptyhua

Reputation: 6692

There should be newline after \ in line RUN curl -L ...

FROM php:8.0-apache

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

RUN sed -i \
      -e 's/"REPLACE_WITH_REAL_KEY"/"COMPANY-KEY"/' \
      -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "company-test"/' \
      -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
      -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
      /usr/local/etc/php/conf.d/newrelic.ini

it worked on my test server

# docker run -it test/newrelic:latest /bin/sh
root@97b9cd183947:/var/www/html# php -r "phpinfo();"|grep newrelic
/usr/local/etc/php/conf.d/newrelic.ini
newrelic
newrelic.daemon.address => @newrelic
newrelic.daemon.app_connect_timeout => 15s
newrelic.daemon.app_timeout => no value

Upvotes: 3

Related Questions