how to set max_execution_time php-fpm docker image?

user7399816 picture user7399816 · Jan 10, 2017 · Viewed 9.9k times · Source

I am using docker image for php5.6-fpm from https://hub.docker.com/_/php/.

When I check php.ini location in phpinfo() it says it is /usr/local/etc/php, but when I look into that path there is no php.ini located there.

Now I want to change max_execution_time php variable. How can I do that in custom docker image?

Answer

Eugen Mayer picture Eugen Mayer · Jan 10, 2017

What you do is, you derive from the official FPM image and then use RUN+sed to change the value, e.g.:

FROM php:7.1

RUN sed -e 's/max_execution_time = 30/max_execution_time = 100/' -i /etc/php/7.1/fpm/php.ini

Please ensure the path /etc/php/7.1/fpm/php.ini is correct in your case, it depends on the image used, i did not verify above the php:7.1 one.

Hint: When you need to change a lot of values, you might rather want to simply use your own php.ini in your image

COPY php.ini /etc/php/7.1/fpm/php.ini

But thats just in case, changing just a few values can be done with sed