一千萬個為什麽

搜索

找不到保存處理程序'redis' - 會話啟動失敗 - 對於PHP



我在加載 index.php 文件時遇到此錯誤。

警告: session_start():找不到保存處理程序'redis' - 第2行的/var/www/html/index.php中的會話啟動失敗

我的index.php代碼如下所示:

<?php
session_start();
$_SESSION['count']=(isset($_SESSION['count']))?$_SESSION['count']+1:1;
$json['time ']= date(' Y-m-d H:i:s');
$json['ip ']=$_SERVER['REMOTE_ADDR'];
$json['count '] = $_SESSION['count'];
echo json_encode($json);

?>

我的dockerfile如下所示:

FROM php:7.1-fpm-alpine

RUN apk update; \
    apk upgrade;

RUN apk add --update \
        autoconf \
        g++ \
        libtool \
                make

RUN pecl install -o -f redis \
&&  rm -rf /tmp/pear \
&&  docker-php-ext-enable redis


# For easy navigating add oh my zsh and it's deps
RUN apk -q add curl \
    zsh \
    nano \
    git; \
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"; \
    sed -i s^ZSH_THEME=\"robbyrussell\"^ZSH_THEME=\"blinks\"^g ~/.zshrc;

# Install Composer
RUN PHP -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"; \
    PHP -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"; \
    PHP composer-setup.php; \
    PHP -r "unlink('composer-setup.php');"; \
    echo 'alias composer="php /var/www/html/composer.phar" > ~/.zshrc';

我的php.ini文件如下所示:

session.save_handler = redis
session.save_path = tcp://192.168.0.24:6379

Redis.conf文件有以下條目:

bind 127.0.0.1 192.168.0.24

我的redis dockerfile如下所示:

FROM redis:3.2-alpine

COPY conf/redis.conf /usr/local/etc/redis/redis.conf
CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ]

EXPOSE 6379

如果我需要提供更多詳細信息,請告訴我。

這可能是什麽問題?

轉載註明原文: 找不到保存處理程序'redis' - 會話啟動失敗 - 對於PHP

一共有 0 個回答: