mcrypt扩展费了一些时间,php自己的bug,pecl上写着8.0支持1.0.3版本,可惜。 具体参考 https://bugs.php.net/bug.php?id=80459 需要其他扩展的参照下面方式,注意是源码安装还是pecl安装即可
FROM php:8.0-fpm-buster
# 更换源
RUN sed -i "s/deb.debian.org/mirrors.aliyun.com/g" /etc/apt/sources.list
RUN apt-get update && apt-get install -y \
libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng-dev \
&& apt-get install -y libmemcached-dev zlib1g-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
# PHP8必须装1.0.4 参考 https://bugs.php.net/bug.php?id=80459
&& pecl install mcrypt-1.0.4 \
&& docker-php-ext-enable mcrypt \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install pdo pdo_mysql \
&& pecl install redis-5.3.2 \
&& docker-php-ext-enable redis \
&& docker-php-ext-install -j$(nproc) bcmath
这里值得注意的地方是:
./www : /data/www
version: "3"
services:
mysql:
container_name: dlnmpr-mysql
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=litblc
- MYSQL_PASSWORD=EGzsj2021^^
ports:
- "13306:3306"
expose:
- "3306"
restart: always
volumes:
- ./docker/mysql/data/:/var/lib/mysql
#- ./docker/mysql/etc/my.cnf:/etc/mysql/my.cnf
networks:
- lnmp
redis:
container_name: dlnmpr-redis
image: redis:5.0
ports:
- "16379:6379"
expose:
- "6379"
volumes:
- ./docker/redis/etc/6379.conf:/usr/local/etc/redis/redis.conf
- ./docker/redis/data:/data
- ./docker/redis/log:/logs
restart: always #重启
networks:
- lnmp
php:
container_name: dlnmpr-php
build:
context: ./docker/php
dockerfile: Dockerfile
expose:
- "9000"
environment:
- TZ=Asia/Shanghai
links:
- mysql
- redis
restart: always
networks:
- lnmp
volumes:
- ./docker/php/etc/php.ini:/usr/local/etc/php/php.ini
- ./docker/php/etc/php-fpm.conf:/usr/local/etc/php-fpm.conf
- ./docker/php/etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf
- ./docker/php/logs/:/var/log/php
- ./www:/data/www
nginx:
container_name: dlnmpr-nginx
image: nginx:1.21
volumes:
- ./docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ./docker/nginx/conf.d/:/etc/nginx/conf.d/
- ./docker/nginx/html:/usr/share/nginx/html
- ./docker/nginx/log/:/var/log/nginx
- ./www:/data/www
ports:
- "9527:80"
- "9443:443"
environment:
- TZ=Asia/Shanghai
restart: always
links:
- php
depends_on:
- mysql
- redis
- php
networks:
- lnmp
networks:
lnmp:
driver: bridge