安装install-php-extensions工具可很好的解决依赖的版本问题
两种方式安装,一种github直接下载启动,一种利用这个工具的docker镜像将二进制文件 拷贝到/usr/bin
所以采用第二种方式前,首先要执行
mlocati/php-extension-installer
FROM php:7.4-fpm
LABEL maintainer="tianye@lzad.cc"
#Download PHP extensions
#ADD https://raw.githubusercontent.com/mlocati/docker-php-extension-installer/master/install-php-extensions /usr/local/bin/
#RUN chmod uga+x /usr/local/bin/install-php-extensions && sync
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN DEBIAN_FRONTEND=noninteractive apt-get update -q \
&& DEBIAN_FRONTEND=noninteractive apt-get install -qq -y \
curl \
git \
zip unzip \
&& install-php-extensions \
bcmath \
bz2 \
calendar \
exif \
gd \
intl \
ldap \
memcached \
mysqli \
opcache \
pdo_mysql \
pdo_pgsql \
pgsql \
redis \
soap \
xsl \
zip \
sockets \
swoole \
yaf \
memcached \
mongodb \
mcrypt \
iconv \
mbstring
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& ln -s $(composer config --global home) /root/composer
ENV PATH=$PATH:/root/composer/vendor/bin COMPOSER_ALLOW_SUPERUSER=1
docker-compose.yml
version: '3'
services:
crm_php:
image: tianye/php:7.4
ports:
- "9009:9000"
volumes:
- "/data/docker/www:/var/www/html"
crm_nginx:
image: nginx
volumes:
- "/data/docker/www:/var/www/html"
- "/etc/localtime:/etc/localtime"
- "/data/docker/nginx/conf.d:/etc/nginx/conf.d"
ports:
- "8013:80"
web.conf
server{
listen 80;
server_name 192.168.1.112;
root /var/www/html;
location / {
index index.html;
}
location ~ \.php$ {
fastcgi_pass docker-compose_crm_php_1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
![](https://img.haomeiwen.com/i21291059/b9387a75d7593e8f.png)
网友评论