docker-php

PHP中安装扩展有几个特殊的命令

  • docker-php-source
  • docker-php-ext-install
  • docker-php-ext-enable
  • docker-php-ext-configure

# 解压php源码到 /usr/src/php
docker-php-source extract

# 安装mysqli 扩展
docker-php-ext-install mysqli

# pecl 安装 redis 扩展
pecl install redis

# 查看下扩展是否生成
ls -ahl ls /usr/local/lib/php/extensions/*
echo extension=redis.so >/usr/local/etc/php/conf.d/pecl-redis.ini

# 重启下 php-fpm container 即可

===============
参考 https://www.cnblogs.com/yinguohai/p/11329273.html

 

===============
php.ini 优化
https://www.php.net/manual/zh/session.configuration.php#ini.session.save-handler

session.save_handler = redis
; session.save_path = "/tmp"
; 改为redis可提升并发量,
; session.save_path = "tcp://172.17.0.1:6379"
session.save_path = "tcp://127.0.0.1:6379"
Use SessionHandlerInterface interface Custom redis session, found the following:
Use ini_set ('session.save_path', "tcp: //127.0.0.1: 6379? Auth = password"); will be reported:
PHP Fatal error: session_start (): Failed to initialize storage module: user (path: tcp: //127.0.0.1: 6379? Auth = password);
程序中可使用语句实现
Using session_save_path ("tcp: //127.0.0.1: 6379?Auth=password") will not
session.save_path = "tcp://127.0.0.1:6379?Auth=redis_password"