关于docker:Docker-PHP-安装扩展

41次阅读

共计 1904 个字符,预计需要花费 5 分钟才能阅读完成。

编写 Dockerfile

vim Dockerfile
FROM php:7.3-fpm

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN chmod +x /usr/local/bin/install-php-extensions && sync && \
    install-php-extensions bcmath bz2 calendar exif gd gettext gmp igbinary imagick memcached mongodb mysqli pcntl pdo_mysql pdo_pgsql pgsql redis shmop sockets swoole sysvmsg sysvsem sysvshm wddx xhprof xsl zip

RUN install-php-extensions @composer

构建镜像并运行

$ docker build -t my-php .

$ docker run -itd --name php -p 9001:9000 \
-v /mnt/website/prod/project-name:/var/www/html \
my-php:latest

反对的扩大

Extension PHP 7.2 PHP 7.3 PHP 7.4 PHP 8.0
amqp
apcu
apcu_bc
bcmath
bz2
calendar
cmark
csv
dba
decimal
ds
enchant
ev
excimer
exif
ffi
gd
gearman
geoip
geospatial
gettext
gmagick
gmp
gnupg
grpc
http
igbinary
imagick
imap
interbase
intl
ioncube_loader
json_post
ldap
mailparse
maxminddb
mcrypt
memcache
memcached
mongodb
mosquitto
msgpack
mysqli
oauth
oci8
odbc
opcache
opencensus
parallel
pcntl
pcov
pdo_dblib
pdo_firebird
pdo_mysql
pdo_oci
pdo_odbc
pdo_pgsql
pdo_sqlsrv
pgsql
propro
protobuf
pspell
raphf
rdkafka
recode
redis
seaslog
shmop
smbclient
snmp
snuffleupagus
soap
sockets
solr
sqlsrv*
ssh2
swoole
sysvmsg
sysvsem
sysvshm
tensor
tidy
timezonedb
uopz
uuid
wddx
xdebug
xhprof
xlswriter
xmlrpc
xsl
yaml
yar
zip
zookeeper
zstd

已有的内置扩大

$ docker run --rm php:7.3-fpm php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

参考:https://github.com/mlocati/do…

正文完
 0