【发布时间】:2019-08-23 18:03:45
【问题描述】:
我的 WordPress 主题抱怨 max_execution_time (30)、max_input_vars (1000) 和 WP Memory Limit (40)。我真的需要在我的网站所在的 docker 容器上增加 PHP 资源和内存。
我尝试手动更改 php.ini 和 .htaccess 文件,但没有成功。据我了解,这些设置需要按照说明在 dockerfile 上完成。
这是我的 dockerfile:
# ========== STAGE FOR BUILDING THE JS/CSS ASSETS
FROM node:9.11.1-slim AS builder
WORKDIR /var/www/
# Install the required packages for building the assets
COPY src/package*.json src/gulpfile.js ./
RUN npm install
# Build the assets
COPY src/wp-content/themes/tsc ./wp-content/themes/tsc
RUN npm run build-prod
# ========== PRODUCTION IMAGE
FROM wordpress:5.0.3-php7.2-fpm
# ---------- Configure PHP
# RUN docker-php-ext-install sockets
# RUN sed -i "s|;pid =.*|pid = /var/run/php-fpm.pid|" /usr/local/etc/php-fpm.conf
# RUN sed -i "s|listen =.*|listen = /var/run/php/php-fpm.sock|" /usr/local/etc/php-fpm.d/www.conf
# RUN sed -i "s|;listen.mode =.*|listen.mode = 0666|" /usr/local/etc/php-fpm.d/www.conf
COPY ./conf/php/* ./conf/php-fpm.conf /usr/local/etc/
COPY ./conf/php-fpm.d/* /usr/local/etc/php-fpm.d/
# ---------- Configure blog files and directories
WORKDIR /var/www/html/
COPY src ./tsc/
COPY --from=builder /var/www/wp-content/themes/tsc/build/ ./tsc/wp-content/themes/tsc/build/
COPY bin /usr/local/bin/
RUN chmod +x /usr/local/bin/start-server.sh
# ---------- Install and configure Nginx
RUN apt-get update && apt-get install -y wget gnupg
RUN wget -O- http://nginx.org/keys/nginx_signing.key > nginx.key && apt-key add nginx.key && rm nginx.key
RUN echo deb http://nginx.org/packages/debian/ stretch nginx > /etc/apt/sources.list.d/nginx.list && \
echo deb-src http://nginx.org/packages/debian/ stretch nginx >> /etc/apt/sources.list.d/nginx.list
RUN apt-get update
RUN apt-get install -y --allow-downgrades --allow-remove-essential --allow-change-held-packages nginx
# Copy nginx and default site conf
COPY conf/nginx.conf /etc/nginx/nginx.conf
COPY conf/nginx-site.conf /etc/nginx/conf.d/default.conf
# ---------- Configure environment
COPY conf/setup-env-vars.sh /tmp/setup-env-vars.sh
RUN chmod +x /tmp/setup-env-vars.sh
# ---------- Run
EXPOSE 80
CMD ["start-server.sh"]
# ---------- Configure debug
RUN sed -i "s|;error_log =.*|error_log = /var/log/fpm-php.www.log|" /usr/local/etc/php-fpm.conf
RUN echo "\ncatch_workers_output = yes" >> /usr/local/etc/php-fpm.d/www.conf
RUN echo "\nphp_flag[display_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
# RUN echo "\nphp_admin_value[error_log] = /var/log/fpm-php.www.log" >> /usr/local/etc/php-fpm.d/www.conf
RUN echo "\nphp_admin_flag[log_errors] = on" >> /usr/local/etc/php-fpm.d/www.conf
# RUN touch /var/log/fpm-php.www.log && chmod 777 /var/log/fpm-php.www.log
# Forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
所以,我需要一些说明来帮助我在我的 docker 容器上实现以下值:
max_input_vars = 5000
max_execution_time = 300
post_max_size = 50M
upload_max_filesize = 50M
【问题讨论】:
-
您使用的是哪个码头工人基地?有时他们会将有效的
php.ini文件放在一个意想不到的位置。 -
我不知道,伙计。我在哪里可以找到这些信息?
-
在您的 Dockerfile 中,有一行以
FROM开头。FROM后面的名称是基础镜像。 -
我用整个 dockerfile 更新了我的问题。
标签: php wordpress docker dockerfile