创建 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

运行容器

挂载物理机内容到 容器内部 可以修改下方的 /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;

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