【问题标题】:How to enable php5-redis using cli?如何使用 cli 启用 php5-redis?
【发布时间】:2018-03-01 23:16:39
【问题描述】:

我有一个 docker 容器,我可以在其中看到所有 php 模块:

root@7b995118fc27:~# php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

正如我们所见,该列表中没有 php5-redis。 当我尝试安装它时,我收到一条消息说它已经安装:

root@7b995118fc27:~# apt-get install php5-redis
Reading package lists... Done
Building dependency tree       
Reading state information... Done
php5-redis is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

我的php版本是5.6

root@7b995118fc27:~# php -v
PHP 5.6.31 (cli) (built: Sep 15 2017 01:12:36) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

所以唯一的结论(如果我没看错的话)是php5-redis安装了但没有启用。

这是我在 Dockerfile 中的内容:

FROM php:5-apache


RUN a2enmod rewrite
RUN a2enmod expires
RUN service apache2 restart
RUN apachectl -M


RUN apt-get update
RUN apt-get install -y php5-redis
RUN apt-get install -y redis-server
RUN php -m


COPY src/ /var/www/html
EXPOSE 80

CMD ["redis-server"]

那么,在这种情况下如何启用php5-redis?

【问题讨论】:

    标签: php docker redis dockerfile


    【解决方案1】:

    您需要添加以下语句以启用 redis 扩展

    RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so
    

    【讨论】:

    猜你喜欢
    • 2021-01-25
    • 2019-02-24
    • 2015-06-12
    • 1970-01-01
    • 2016-07-20
    • 2017-04-07
    • 1970-01-01
    • 2010-11-11
    • 1970-01-01
    相关资源
    最近更新 更多