apm-agent-php icon indicating copy to clipboard operation
apm-agent-php copied to clipboard

Error installing Elastic PHP agent

Open malf88 opened this issue 2 years ago • 2 comments

Describe the bug I'm trying to install Elastic PHP agent in a container with the image php:8.2.0-fpm and it's giving me the following error:

58.44 Failed. The supported PHP versions are 7.2-8.2. 58.44 Failed. Elastic PHP agent extension is not supported for the existing PHP installation. 58.44 dpkg: error processing package apm-agent-php (--install): 58.44 installed apm-agent-php package post-installation script subprocess returned error exit status 1 58.51 Errors were encountered while processing:

To Reproduce Steps to reproduce the behavior:

  1. Build image com php:8.2.0-fpm installing the extension according to the documentation
wget https://github.com/elastic/apm-agent-php/releases/download/v1.10.0/apm-agent-php_1.10.0_all.deb && \
dpkg -i apm-agent-php_1.10.0_all.deb

and enabling the extension

extension=elastic_apm.so

elastic_apm.server_url=xxxx
elastic_apm.service_name="xxxx"

Expected behavior Since the documentation says it supports php 7.2 - 8.2 I expected it to install correctly.

malf88 avatar Nov 03 '23 12:11 malf88

Minimum Reproducible:

Dockerfile

`FROM alpine:3.18.4

ENV APM_VERSION=1.10.0

RUN apk add --no-cache supervisor
nginx
libsodium
php82
php82-fpm
php82-session
php82-opcache
php82-pecl-redis
php82-ctype
php82-exif
php82-gd
php82-phar
php82-fileinfo
php82-mysqli
php82-pecl-imagick
php82-zip
php82-intl
php82-simplexml
php82-iconv
php82-dom
php82-curl
php82-xml
php82-xmlreader
php82-openssl
php82-mbstring
php82-xmlwriter
php82-sodium
php82-ldap
php82-tokenizer

RUN apk --no-cache add --virtual build-dependencies
git \ alpine-sdk
curl-dev
rpm
&& mkdir -p /opt/apm-agent
&& cd /opt/apm-agent
&& curl -v -O https://github.com/elastic/apm-agent-php/releases/download/v${APM_VERSION}/apm-agent-php_${APM_VERSION}all.apk -L
&& apk add --allow-untrusted /opt/apm-agent/apm-agent-php
${APM_VERSION}_all.apk -vvv
&& apk del build-dependencies`

When you change php81 to php82, the PHP Version returns ".", indicating a failed concatenate.

The function performing this is in post-install.sh:

function php_command() {
    PHP_BIN=$(command -v php)
    ${PHP_BIN} -d memory_limit=128M "$@"
}

This appears to be an issue with php 8.2 and not the Elastic Agent itself. In PHP 8.2, the "php" command is actually "php82", so the environmental variable "PHP_BIN" fails to correctly use the path to the php binary.

#1097 is very relevant to this request at this time.

A workaround I made for now is if you're using php82 to ensure you have either a symlink or a copy pointed at /usr/bin/php

6fears7 avatar Nov 27 '23 18:11 6fears7

Yea... In my alpine image and php8.1 I simply do: ln -s /usr/bin/php81 /usr/bin/php after php installation.

hetii avatar Dec 29 '23 15:12 hetii