karoid/nginx-php-fpm7
# docker buildx create --use
# docker buildx build --platform linux/amd64,linux/arm64 -t karoid/nginx-php-fpm7:1.21.5-alpine -t karoid/nginx-php-fpm7:latest --push .
FROM nginx:1.21.5-alpine
ENV fpm_conf /etc/php7/php-fpm.d/www.conf
ENV php_vars /etc/php7/conf.d/docker-vars.ini
RUN apk update -qq \
&& apk add php7-fpm php7-session php7-pgsql \
&& echo "cgi.fix_pathinfo=0" > ${php_vars} \
&& echo "upload_max_filesize = 100M" >> ${php_vars} \
&& echo "post_max_size = 100M" >> ${php_vars} \
&& echo "variables_order = \"EGPCS\"" >> ${php_vars} \
&& echo "memory_limit = 128M" >> ${php_vars} \
&& sed -i \
-e "s/;catch_workers_output\s*=\s*yes/catch_workers_output = yes/g" \
-e "s/pm.max_children = 5/pm.max_children = 4/g" \
-e "s/pm.start_servers = 2/pm.start_servers = 3/g" \
-e "s/pm.min_spare_servers = 1/pm.min_spare_servers = 2/g" \
-e "s/pm.max_spare_servers = 3/pm.max_spare_servers = 4/g" \
-e "s/;pm.max_requests = 500/pm.max_requests = 200/g" \
-e "s/user = www-data/user = nginx/g" \
-e "s/group = www-data/group = nginx/g" \
-e "s/;listen.mode = 0660/listen.mode = 0666/g" \
-e "s/;listen.owner = www-data/listen.owner = nginx/g" \
-e "s/;listen.group = www-data/listen.group = nginx/g" \
-e "s/listen = 127.0.0.1:9000/listen = \/var\/run\/php-fpm.sock/g" \
-e "s/^;clear_env = no$/clear_env = no/" \
${fpm_conf} \
&& mkdir /etc/nginx/snippets
COPY fastcgi-php.conf /etc/nginx/snippets/
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 80
# to reload nginx: nginx -s reload -c /etc/nginx/nginx.conf
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
entrypoint.sh
#!/bin/sh
set -e
# Run php-fpm.
echo "### php-fpm started ###"
php-fpm7
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "$@"
fastcgi-php.conf
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
docker pull karoid/nginx-php-fpm7