Dockfile
FROM php:7.2.13-fpm
RUN sed -i "s@http://deb.debian.org@http://mirrors.aliyun.com@g" /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
EXPOSE 80
CMD ["/usr/bin/supervisord"]
supervisord.conf
; supervisor config file
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[supervisord]
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
nodaemon=true
; 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
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
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.
[include]
files = /etc/supervisor/conf.d/*.conf
[program:php]
command=/usr/local/sbin/php-fpm --nodaemonize
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
[program:cron]
command=cron -f