Skip to content

PHP Startup: Unable to load dynamic library 'redis.so' #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
beejaz opened this issue Oct 16, 2020 · 15 comments · Fixed by #227
Closed

PHP Startup: Unable to load dynamic library 'redis.so' #213

beejaz opened this issue Oct 16, 2020 · 15 comments · Fixed by #227

Comments

@beejaz
Copy link

beejaz commented Oct 16, 2020

Expected Behavior

Enable redis support in PHP in thecodingmachine/php:7.4-v3-slim-fpm

Current Behavior

Container crashing on start or giving constant errors on load.

Possible Solution

As discussed in #200 maybe add delay or other order of loading

Steps to Reproduce (for bugs)

php/Dockerfile:

ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql ldap redis intl imap"
ARG NODE_VERSION=10
FROM thecodingmachine/php:7.4-v3-slim-fpm as php7.4-base-node10

docker-compose.yml:

  php:
    container_name: 'php'
    build:
      context: ./php
    environment:
      PHP_EXTENSION_REDIS: 1
      PHP_EXTENSION_GETTEXT: 1
      PHP_EXTENSION_PDO: 1
      PHP_EXTENSION_PDO_MYSQL: 1
      PHP_EXTENSION_LDAP: 1
      PHP_EXTENSION_INTL: 1

docker-compose up

php      | PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php      | /usr/local/bin/docker-entrypoint-as-root.sh: line 129: supercronic: command not found
php      | PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php      | bash: line 2: syntax error near unexpected token `('
php      | bash: line 2: `Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0'

When disabling PHP_EXTENSION_REDIS: 0 it starts:

php      | [16-Oct-2020 09:34:05] NOTICE: fpm is running, pid 1845
php      | [16-Oct-2020 09:34:05] NOTICE: ready to handle connections
php      | [16-Oct-2020 09:34:05] NOTICE: systemd monitor interval set to 10000ms

On another container that has redis in ARG PHP_EXTENSIONS i get this error everytime i do something in console with php:

PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

Context

Im trying to enable redis support in the image. If i turn off redis PHP_EXTENSION_REDIS: 0 i wont get any errors, but if I turn it on, it will either crash on start or if it runs, php will give error when trying to use redis for connection.
Similar problem discussed here #200 but i didn't find any solution.

Your Environment

  • Version used: thecodingmachine/php:7.4-v3-slim-fpm
  • Operating System and version: Native Linux Ubuntu 20.04 and aslo Windows 2004 with WSL2 Ubuntu 20.04 and Docker for windows
@mbrodala
Copy link
Contributor

mbrodala commented Nov 5, 2020

Do you use docker-composer up followed by exec or do you use docker-compose run? The latter is safe, the former can lead to a race condition with errors like this.

@beejaz
Copy link
Author

beejaz commented Nov 6, 2020

Hi @mbrodala thanks for your response, I use docker-compose up -d with this

version: '3.1'

services:
  php:
    build:
      context: ./php
      args:
        - PHP_ROOT_DIR=/usr/local/etc
    environment:
      TEMPLATE_PHP_INI: development
      PHP_EXTENSION_GETTEXT: 1
      PHP_EXTENSION_PDO: 1
      PHP_EXTENSION_PDO_MYSQL: 1
      PHP_EXTENSION_LDAP: 1
      PHP_EXTENSION_INTL: 1
      PHP_EXTENSION_REDIS: 1
    volumes:
      - ./project:/var/www/html
      - ./logs/php:/usr/local/etc/logs
      - ./logs/php:/usr/local/var/log

If i run "docker-compose run php -d" it will give me error also:

❯ docker-compose run php -d
Creating network "toolbox_default" with the default driver
Creating toolbox_php_run ... done
PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
/usr/local/bin/docker-entrypoint-as-root.sh: line 129: supercronic: command not found
PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
bash: line 2: syntax error near unexpected token `('
bash: line 2: `Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0'

@mbrodala
Copy link
Contributor

mbrodala commented Nov 6, 2020

undefined symbol: igbinary_serialize

This sounds like a loading issue since redis.so looks like being built with igbinary support but that extension is not loaded or in a wrong version.

@moufmouf I can see the install.sh of redis which does not have DEPENDENCIES like the memcached version which it is obviously based on:

https://github.com/thecodingmachine/docker-images-php/blob/c4bce49e16b69a4121e2da54fb95a9e467902768/extensions/core/redis/install.sh
https://github.com/thecodingmachine/docker-images-php/blob/c4bce49e16b69a4121e2da54fb95a9e467902768/extensions/core/memcached/install.sh

Could this be the reason?

@beejaz
Copy link
Author

beejaz commented Nov 8, 2020

I tried adding memcached to my Dockerfile and PHP_EXTENSION_MEMCACHED: 1 to docker-compose.yml which ended up showing more errors after a fresh docker-compose build php

php_1    | PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php_1    | PHP Warning:  PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/lib/php/20190902/memcached.so (/usr/lib/php/20190902/memcached.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/memcached.so.so (/usr/lib/php/20190902/memcached.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
php_1    | bash: line 2: syntax error near unexpected token `('
php_1    | bash: line 2: `Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20190902/redis.so (/usr/lib/php/20190902/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/redis.so.so (/usr/lib/php/20190902/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0'

Ive tried to find information about this issue, some say its a issue with Ubuntu 18.04 and php/redis. Some suggest to change order of loading extensions;
20-igbinary.ini
30-redis.ini

Some other suggest installing the stuff you mentioned above @mbrodala
sudo apt-get install php-igbinary
sudo apt-get install php-msgpack

@moufmouf
Copy link
Member

Sorry for the delay.
@beejaz I'm working on a v4 of the Docker image based on Ubuntu 20.04. It does not have this issue. I'll keep you posted.

@beejaz
Copy link
Author

beejaz commented Dec 1, 2020

Sorry for the delay.
@beejaz I'm working on a v4 of the Docker image based on Ubuntu 20.04. It does not have this issue. I'll keep you posted.

I love your work, no worries! Thank you very much, Ill wait patiently

@moufmouf moufmouf mentioned this issue Dec 4, 2020
9 tasks
@robjuz
Copy link

robjuz commented Dec 14, 2020

@beejaz I'm sorry but it is stil not working.

I would love to use the phpredis extention in my laravel project running laravel horizon.

ARG PHP_EXTENSIONS="bcmath pdo_sqlite redis"
FROM thecodingmachine/php:8.0-v4-slim-apache

ENV APACHE_DOCUMENT_ROOT=public/ \
    APACHE_RUN_USER=www-data \
    APACHE_RUN_GROUP=www-data
...

docker run --rm php artisan horizon

PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20200930/redis.so (/usr/lib/php/20200930/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20200930/redis.so.so (/usr/lib/php/20200930/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
/usr/local/bin/docker-entrypoint-as-root.sh: line 132: supercronic: command not found
PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20200930/redis.so (/usr/lib/php/20200930/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20200930/redis.so.so (/usr/lib/php/20200930/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
bash: line 2: syntax error near unexpected token `('
bash: line 2: `Warning: PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib/php/20200930/redis.so (/usr/lib/php/20200930/redis.so: undefined symbol: igbinary_serialize), /usr/lib/php/20200930/redis.so.so (/usr/lib/php/20200930/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0'

@moufmouf
Copy link
Member

Ok, I'll check that!

@robjuz
Copy link

robjuz commented Dec 16, 2020

@moufmouf
Maybe this will help.

I tried to build my own image based on Ubuntu 20.04 and come to the same problem. After some googling I found out that there is a problem with the extension loading order.

This is working

FROM ubuntu:20.04

RUN apt-get update -y
RUN apt-get install -y php7.4-redis


RUN echo 'priority=20' >> /etc/php/7.4/mods-available/igbinary.ini
RUN echo 'priority=30' >> /etc/php/7.4/mods-available/redis.ini

This image is using the ondrej/php repository. I don't know why, but it is not working with its version.

So cloned this repo, emoved the ondrej/php, installed the extension, ran phpdismod igbinary redis changed the priority, enabled the extensions.

Working!

@robjuz
Copy link

robjuz commented Dec 22, 2020

@moufmouf any update on this? Maybe the issue should be reopened?

@beejaz
Copy link
Author

beejaz commented Jan 8, 2021

I just tried the latest v4 fpm slim image, got the same error also fyi @moufmouf :)

@robjuz
Copy link

robjuz commented Jan 28, 2021

@moufmouf Can you give us a quick note what do you think about this issue? I really love you images and this is a serious problem.

@beejaz
Copy link
Author

beejaz commented Mar 9, 2021

@moufmouf Hi, sorry to disturb you, any updates here?

@bustersky
Copy link

I came across the same issue and got to the solution...
If you use a slim image you have to enable igbinary alongside with the redis one, as they are enabled by default in fat images only: https://github.com/thecodingmachine/docker-images-php#fat-image

So in case of @beejaz that would be:

version: '3.1'

services:
php:
build:
context: ./php
args:
- PHP_ROOT_DIR=/usr/local/etc
environment:
TEMPLATE_PHP_INI: development
PHP_EXTENSION_GETTEXT: 1
PHP_EXTENSION_PDO: 1
PHP_EXTENSION_PDO_MYSQL: 1
PHP_EXTENSION_LDAP: 1
PHP_EXTENSION_INTL: 1
PHP_EXTENSION_IGBINARY: 1
PHP_EXTENSION_REDIS: 1
volumes:
- ./project:/var/www/html
- ./logs/php:/usr/local/etc/logs
- ./logs/php:/usr/local/var/log

And in case of @robjuz

ARG PHP_EXTENSIONS="bcmath pdo_sqlite igbinary redis"
FROM thecodingmachine/php:8.0-v4-slim-apache

ENV APACHE_DOCUMENT_ROOT=public/
APACHE_RUN_USER=www-data
APACHE_RUN_GROUP=www-data
...

I hope this will help you.

@beejaz
Copy link
Author

beejaz commented Apr 29, 2021

This works for me now with the comment from above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants