如何在Docker PHP容器中非dockerfile解决event扩展加载失败的问题?

在乌班图的服务器里面,在docker容器里面安装扩展,非执行dockerfile,然后执行步骤为

1. docker-php-ext-install pdo_mysql opcache sockets
    docker-php-ext-enable sockets
    pecl install event
    docker-php-ext-enable event

2.执行最后一步也出现了

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

3.网上说event插件需要最后安装,我也是最后安装的,但是永远都会出现这个问题,
后面又在AI上面看到了这一步

echo "extension=event.so" >> /usr/local/etc/php/conf.d/docker-php-ext-event.ini
echo "extension=sockets.so" >> /usr/local/etc/php/conf.d/docker-php-ext-sockets.ini

加入后,还是一样的

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

Warning: Module "sockets" is already loaded in Unknown on line 0

这个需要怎么去解决呢

参考过https://github.com/docker-library/php/issues/857的安装流程,

阅读 1.4k
1 个回答

你贴的那个 Issuse 里面,下面的那个解决方案是可以的呀,在 docker-php-ext-enable 的时候,指定一下 --ini-name 参数,利用命名规则,让 event 在 sockets 后面启用就好了。

# 如果现在已经手动启用过,就删除掉这个配置
rm /usr/local/etc/php/conf.d/docker-php-ext-event.ini
docker-php-ext-enable --ini-name z999-docker-php-ext-event.ini event

image.png


image.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏