创建 uploads.ini

1
2
3
4
5
file_uploads = On
memory_limit = 64 M
upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 600

创建 Dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
FROM php:7.3-fpm

RUN apt-get update
RUN apt-get install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev

EXPOSE 9000

#上传配置成20M
COPY uploads.ini /usr/local/etc/php/conf.d

RUN docker-php-ext-install mysqli
RUN docker-php-ext-install pdo
RUN docker-php-ext-install pdo_mysql
RUN pecl install redis-4.2.0 && docker-php-ext-enable redis
RUN docker-php-ext-install bcmath
RUN docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-png-dir=/usr/include --with-jpeg-dir=/usr/include --with-freetype-dir=/usr/include/freetype2
RUN docker-php-ext-install gd

Docker build

1
docker build -t ai0by/php-fpm73:v1 .

运行容器

挂载物理机内容到 容器内部 可以修改下方的 /var/www/html/workspace 为你的项目地址

1
docker run -v /var/www/html/workspace:/var/www/html/workspace  -p 9002:9000 -d php73:0.1

Nginx配置

修改 fastcgi_pass 后面的 值为 127.0.0.1:9002

LNMP用户 修改 /usr/local/nginx/conf/enable-php-pathinfo.conf

fastcgi_pass unix:/tmp/php-cgi.sock; 修改为 fastcgi_pass 127.0.0.1:9002;

其他环境与此类似,直接改即可

MySQL Docker启动

自行修改 挂载路径 以及 密码

1
docker run --restart=always --name mysql5.7 -p 3306:3306 -v /Users/XXX/Downloads/Docker/mysql5.7:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

Nginx 个人不习惯扔Docker中,因此暂时不管