Press "Enter" to skip to content

docker 搭建 PHP 开发环境(不带Mysql)


FROM php:7.2.13-fpm 

RUN sed -i "s@" /etc/apt/sources.list && \ rm -Rf /var/lib/apt/lists/* && \ 
apt-get update && \ 
apt-get install -y vim wget curl telnet git zlib1g-dev && \ 
/bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone && \ 
docker-php-ext-install zip pdo pdo_mysql opcache mysqli && \ 
apt-get install -y nginx supervisor && \ 
rm -rf /tmp/pear && \ 
apt-get clean && rm -rf /var/cache/apt/* && \ 
cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini && \ 
# 安装 gd 相关库 
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev && \ 
# 下载 PHP 扩展并解压到 /usr/src/php/ext 目录 
docker-php-source extract && \ 
# 进入 gd 源码文件夹 
cd /usr/src/php/ext/gd && \ 
# 相关扩展配置 
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2 && \ 
# 编译安装并启用 gd 扩展 
docker-php-ext-install gd 

COPY ./supervisord.conf /etc/supervisor/ 

WORKDIR /var/www/html 


CMD ["/usr/bin/supervisord"]



; supervisor config file

file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/ ; (supervisord pidfile;default
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)


; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

files = /etc/supervisor/conf.d/*.conf

command=/usr/local/sbin/php-fpm --nodaemonize

command=/usr/sbin/nginx -g 'daemon off;'

command=cron -f



您的电子邮箱地址不会被公开。 必填项已用*标注