morpheus
morpheus

Reputation: 20350

Failed loading /usr/lib/php7/modules/xdebug.so: Error relocating /usr/lib/php7/modules/xdebug.so: php_sprintf: symbol not found

we are trying to install XDebug inside a Docker container based on Alpine Linux and running php-fpm. We followed the installation instructions given at this page. It says to run following for Alpine Linux which is what we did:

bash-5.0# apk add php7-pecl-xdebug
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/2) Installing php7-common (7.3.22-r0)
(2/2) Installing php7-pecl-xdebug (2.9.1-r0)
OK: 85 MiB in 74 packages

we could then see the .so file is under /usr/lib/php7/modules/xdebug.so and so we added it to our /usr/local/etc/php/php.ini like so:

zend_extension = /usr/lib/php7/modules/xdebug.so

Then we restarted the container. The webpage says to verify the installation by running:

bash-5.0# php -v

when we run the command this is the output we get:

bash-5.0# php -v
Failed loading /usr/lib/php7/modules/xdebug.so:  Error relocating /usr/lib/php7/modules/xdebug.so: php_sprintf: symbol not found
PHP 7.4.4 (cli) (built: Mar 24 2020 01:34:16) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.4, Copyright (c), by Zend Technologies

How can we fix this? Thanks. In case it helps:

bash-5.0# ls -al /usr/lib/php7/modules/xdebug.so
-rwxr-xr-x    1 root     root        268088 Jan 18  2020 /usr/lib/php7/modules/xdebug.so

Upvotes: 1

Views: 935

Answers (1)

morpheus
morpheus

Reputation: 20350

I think this error comes from some C library that is not installed on the system. We performed following steps from this answer and it worked. It also installs latest version of xdebug (version 3.0.2). apk add php7-pecl-xdebug was installing version 2.9 of xdebug.

Step 1: Install dependencies:

apk --no-cache add pcre-dev ${PHPIZE_DEPS}

Step 2: Build binary from sources:

pecl install xdebug

On success it should end with

Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so" to php.ini

Step 3: Now edit php.ini and set zend_extension to path given above

Step 4: Verify

bash-5.0# php -v
PHP 7.4.4 (cli) (built: Mar 24 2020 01:34:16) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v7.4.4, Copyright (c), by Zend Technologies

Upvotes: 1

Related Questions