使用Docker构建PHP7.4镜像,并添加redis,zip模块等
默认的官方php docker镜像是不带redis扩展的,甚至连gd、opcache、pdo_mysql等扩展也要自己配置。
修改镜像源文件,sources.list内容如下:
deb http://mirrors.aliyun.com/debian/ buster main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ buster main contrib non-free
deb http://mirrors.aliyun.com/debian-security/ buster/updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian-security/ buster/updates main contrib non-free
deb http://mirrors.aliyun.com/debian/ buster-updates main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ buster-updates main contrib non-free
deb http://mirrors.aliyun.com/debian/ buster-backports main contrib non-free
deb-src http://mirrors.aliyun.com/debian/ buster-backports main contrib non-free
以下是Dockerfile文件内容:
FROM php:7.4-fpm
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
COPY sources.list /etc/apt/sources.list
RUN apt-get update && echo y| apt-get install \
--no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev zlib1g=1:1.2.11.dfsg-1+deb10u2 zlib1g-dev libzip-dev \
&& rm -r /var/lib/apt/lists/* \
&& docker-php-ext-configure gd \
&& docker-php-ext-install -j$(nproc) gd opcache pdo_mysql gettext sockets zip
RUN pecl install redis \
&& docker-php-ext-enable redis
ENV COMPOSER_HOME /root/composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
ENV PATH $COMPOSER_HOME/vendor/bin:$PATH
构建镜像命令:
docker build -t new_php:7.4 .
然后参考这篇文章使用:https://www.cnblogs.com/hahaha111122222/p/17628951.html
访问效果
查看依赖包
# php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
sockets
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
若是想安装其他模块, 需要先在这个网站上查询一下,确定有安装包的话,修改一下Dockerfile文件,再进行安装
http://pecl.php.net/package-stats.php
模块依赖配置文件路径:/usr/local/etc/php/conf.d
php配置文件路径:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2019-08-14 下载MySQL的rpm包安装MySQL
2019-08-14 使用Jenkins结合Gogs和SonarQube对项目代码进行测试、部署、回滚,以及使用keepalived+haproxy调度至后端tomcat
2019-08-14 Gogs官方帮助文档
2019-08-14 Centos7 用gogs搭建git仓库
2018-08-14 Python进阶