laradock是对PHP-Laravel构建的一个环境服务
构建环境前修改配置
文件: cp .env.example .env
WORKSPACE_TIMEZONE=PRC #原来的UTC修改成RPC(不修改可能导致容器中的时间有误差)
文件: docker.compose.yml
# Tip: 如果不科学上网构建过程会有各种错误.代理ip不能是127.0.0.1如果填127这个地址就是容器本身了要填局域网(宿主IP)
- http_proxy=http://[代理ip]:[代理port]
- https_proxy=http://[代理ip]:[代理port]
Q&A
Q1: 构建php-fpm失败 错误信息如下
Step 8/179 : RUN if [ ${CHANGE_SOURCE} = true ]; then sed -i 's/deb.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list && sed -i 's/security.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list && sed -i 's/security-cdn.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list ;fi
---> Running in da1dfe176232
Removing intermediate container da1dfe176232
---> 02d393dc19d7
Step 9/179 : RUN set -xe; apt-get update -yqq && pecl channel-update pecl.php.net && apt-get install -yqq apt-utils gnupg2 git libzip-dev zip unzip && if [ ${LARADOCK_PHP_VERSION} = 7.3 ] || [ ${LARADOCK_PHP_VERSION} = 7.4 ] || [ $(php -r echo PHP_MAJOR_VERSION;) = 8 ]; then docker-php-ext-configure zip; else docker-php-ext-configure zip --with-libzip; fi && docker-php-ext-install zip && php -m | grep -q 'zip'
---> Running in 5319396d9e47
+ apt-get update -yqq
E: Release file for http://deb.debian.org/debian/dists/buster-updates/InRelease is not valid yet (invalid for another 3d 8h 52min 40s). Updates for this repository will not be applied.
E: Release file for http://security.debian.org/debian-security/dists/buster/updates/InRelease is not valid yet (invalid for another 2d 6h 35min 29s). Updates for this repository will not be applied.
The command '/bin/sh -c set -xe; apt-get update -yqq && pecl channel-update pecl.php.net && apt-get install -yqq apt-utils gnupg2 git libzip-dev zip unzip && if [ ${LARADOCK_PHP_VERSION} = 7.3 ] || [ ${LARADOCK_PHP_VERSION} = 7.4 ] || [ $(php -r echo PHP_MAJOR_VERSION;) = 8 ]; then docker-php-ext-configure zip; else docker-php-ext-configure zip --with-libzip; fi && docker-php-ext-install zip && php -m | grep -q 'zip'' returned a non-zero code: 100
ERROR: Service 'php-fpm' failed to build : Build failed
A1: 处理
错误提示的是: 文件无效
原因: 构建环境是在vbox-centos虚拟机上的、由于系统的时间不准确导致
确认当前系统时区: timedatectl status|grep 'Time zone'
确认当前系统时间: date
安装同步系统时间工具: yum -y install ntpdate
同步当前系统时间: ntpdate -u pool.ntp.org
Q: php文件上传大小限制
wordpress 上传限制 默认限制是2M
PHP.INI配置修改
upload_max_filesize = 2048M
post_max_size = 2048M
memory_limit = 2560M
nginx.conf配置修改
client_max_body_size 2048M;
可能重启会发现配置文件并没生效
因为php-fpm使用的是laravel.ini和nginx.conf文件,而这个配置文件是在构建阶段放到镜像中的。所有解决方法有两种。
- 修改配置重新构建
- 修改
docker-compose.yml
文件,把配置文件增加一行volumes