diff --git a/CHANGELOG.md b/CHANGELOG.md index 0573054..33367e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 7.1.0 2022-10-01 + + ### Added + - Convert to using update_template functions when configuring + + ### Changed + - Fix an error where sample php file wasn't being created properly + + ## 7.0.11 2022-09-16 ### Changed diff --git a/Dockerfile.debian b/Dockerfile.debian index 3fa75eb..e214671 100644 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -33,7 +33,9 @@ ENV PHP_BASE=${PHP_BASE:-"8.0"} \ PHP_ENABLE_XMLREADER=TRUE \ PHP_ENABLE_XMLWRITER=TRUE \ CONTAINER_ENABLE_MESSAGING=TRUE \ - NGINX_ENABLE_CREATE_SAMPLE_HTML=FALSE + NGINX_ENABLE_CREATE_SAMPLE_HTML=FALSE \ + IMAGE_NAME="tiredofit/nginx-php-fpm" \ + IMAGE_REPO_URL="https://github.com/tiredofit/docker-nginx-php-fpm/" ### Dependency Installation RUN export PHP_7_3_RUN_DEPS=" \ diff --git a/install/assets/functions/20-php-fpm b/install/assets/functions/20-php-fpm index fd700cc..9b46d4d 100755 --- a/install/assets/functions/20-php-fpm +++ b/install/assets/functions/20-php-fpm @@ -126,8 +126,8 @@ EOF fi if var_false "${PHP_KITCHENSINK}" ; then + php_enable_create_sample_php=${PHP_ENABLE_CREATE_SAMPLE_PHP} unset PHP_ENABLE_CREATE_SAMPLE_PHP # legacy - unset PHP_ENABLE_DISPLAY_ERRORS # legacy php_env_plugins_enabled=$(set -o posix; set | sort | grep PHP_ENABLE_ | grep -i TRUE |sed -e 's/PHP_ENABLE_//g' | sed -e 's/=TRUE//g' | awk -vRS="" -vOFS=', ' '$1=$1' | tr A-Z a-z) for module in $(echo "${php_env_plugins_enabled}" | tr "," "\n" ) ; do if [ -f "${php_prefix}"/mods-available/${module}.ini ]; then @@ -140,6 +140,7 @@ EOF done print_notice "PHP-FPM Preparing to start with the following plugins enabled: ${php_actual_plugins_enabled}" else + php_enable_create_sample_php=${PHP_ENABLE_CREATE_SAMPLE_PHP} print_warn "Enabling Kitchen Sink mode and allowing all plugins to be active" silent php-ext enable all fi @@ -162,7 +163,7 @@ phpfpm_configure_logging() { ;; esac - sed -i -e "s//${PHP_LOG_LEVEL}/g" /assets/php-fpm/fpm/php-fpm.conf + update_template /assets/php-fpm/fpm/php-fpm.conf PHP_LOG_LEVEL } phpfpm_configure_nginx() { @@ -191,33 +192,39 @@ phpfpm_configure_nginx() { phpfpm_configure_server() { if [ "${PHP_BASE:0:1}" = "5" ] ; then echo "suhosin.executor.include.whitelist = phar" >> /etc/php"${PHP_BASE:0:1}"/php.ini ; fi truefalse_onoff PHP_DISPLAY_ERRORS - sed -i "s||${PHP_DISPLAY_ERRORS}|g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_LISTEN_PORT}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_MAX_CHILDREN}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_TIMEOUT}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_MAX_REQUESTS}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_MAX_SPARE_SERVERS}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_START_SERVERS}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_MIN_SPARE_SERVERS}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_OUTPUT_BUFFER_SIZE}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_HOST}#g" /etc/nginx/snippets/php-fpm.conf - sed -i -e "s##${PHP_FPM_LISTEN_PORT}#g" /etc/nginx/snippets/php-fpm.conf - sed -i -e "s##${PHP_LOG_LOCATION}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_LOG_ACCESS_FILE}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_LOG_ERROR_FILE}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_LOG_LIMIT}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_MEMORY_LIMIT}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_TIMEOUT}#g" /etc/nginx/snippets/php-fpm.conf - sed -i -e "s##${PHP_POST_MAX_SIZE}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_FPM_PROCESS_MANAGER}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s##${PHP_UPLOAD_MAX_SIZE}#g" /assets/php-fpm/fpm/php-fpm.conf - sed -i -e "s#apc.shm_size.*#apc.shm_size=${PHP_APC_SHM_SIZE}#g" /assets/php-fpm//mods-available/apcu.ini - sed -i -e "s#opcache.memory_consumption.*#opcache.memory_consumption=$PHP_OPCACHE_MEM_SIZE#g" /assets/php-fpm/mods-available/opcache.ini - sed -i -e "s#memory_limit = .*#memory_limit = ${PHP_MEMORY_LIMIT}#g" /assets/php-fpm/cli/php.ini - sed -i -e "s#max_input_time = .*#max_input_time = ${PHP_TIMEOUT}#g" /assets/php-fpm/cli/php.ini - sed -i -e "s#default_socket_timeout = .*#default_socket_timeout = ${PHP_TIMEOUT}#g" /assets/php-fpm/cli/php.ini - sed -i -e "s#post_max_size = .*#post_max_size = ${PHP_UPLOAD_MAX_SIZE}#g" /assets/php-fpm/cli/php.ini - sed -i -e "s#upload_max_filesize = .*#upload_max_filesize = ${PHP_UPLOAD_MAX_SIZE}#g" /assets/php-fpm/cli/php.ini + update_template /assets/php-fpm/fpm/php-fpm.conf \ + NGINX_USER \ + NGINX_GROUP \ + PHP_DISPLAY_ERRORS \ + PHP_FPM_HOST \ + PHP_FPM_LISTEN_PORT \ + PHP_FPM_LISTEN_PORT \ + PHP_FPM_MAX_CHILDREN \ + PHP_FPM_MAX_REQUESTS \ + PHP_FPM_MAX_SPARE_SERVERS \ + PHP_FPM_MIN_SPARE_SERVERS \ + PHP_FPM_OUTPUT_BUFFER_SIZE \ + PHP_FPM_PROCESS_MANAGER \ + PHP_FPM_START_SERVERS \ + PHP_LOG_ACCESS_FILE \ + PHP_LOG_ERROR_FILE \ + PHP_LOG_LIMIT \ + PHP_LOG_LOCATION \ + PHP_MEMORY_LIMIT \ + PHP_POST_MAX_SIZE \ + PHP_TIMEOUT \ + PHP_UPLOAD_MAX_SIZE + + update_template /etc/nginx/snippets/php-fpm.conf PHP_TIMEOUT + + sed -i "s#apc.shm_size.*#apc.shm_size=${PHP_APC_SHM_SIZE}#g" /assets/php-fpm//mods-available/apcu.ini + sed -i "s#opcache.memory_consumption.*#opcache.memory_consumption=$PHP_OPCACHE_MEM_SIZE#g" /assets/php-fpm/mods-available/opcache.ini + sed -i -e "s#memory_limit = .*#memory_limit = ${PHP_MEMORY_LIMIT}#g" \ + -e "s#max_input_time = .*#max_input_time = ${PHP_TIMEOUT}#g" \ + -e "s#default_socket_timeout = .*#default_socket_timeout = ${PHP_TIMEOUT}#g" \ + -e "s#post_max_size = .*#post_max_size = ${PHP_UPLOAD_MAX_SIZE}#g" \ + -e "s#upload_max_filesize = .*#upload_max_filesize = ${PHP_UPLOAD_MAX_SIZE}#g" \ + /assets/php-fpm/cli/php.ini if [ -n "${PHP_IDE_CONFIG}" ]; then if [[ "${PHP_IDE_CONFIG}" = \"* ]] || [[ "${PHP_IDE_CONFIG}" = \'* ]] ; then @@ -230,9 +237,8 @@ phpfpm_configure_server() { sed -i -e "s#date.timezone = .*#date.timezone = $(cat /etc/timezone)#g" /assets/php-fpm/cli/php.ini sed -i -e "s#date.timezone = .*#date.timezone = $(cat /etc/timezone)#g" /assets/php-fpm/fpm/php.ini } - phpfpm_create_default_page() { - if var_true "${PHP_ENABLE_CREATE_SAMPLE_PHP}" ; then + if var_true "${php_enable_create_sample_php}" ; then if [ ! -f "${NGINX_WEBROOT}"/index.php ] ; then print_notice "Creating sample index.php" mkdir -p "${NGINX_WEBROOT}" diff --git a/install/assets/php-fpm/fpm/php-fpm.conf b/install/assets/php-fpm/fpm/php-fpm.conf index e769174..ed2f89c 100644 --- a/install/assets/php-fpm/fpm/php-fpm.conf +++ b/install/assets/php-fpm/fpm/php-fpm.conf @@ -1,35 +1,35 @@ -error_log = / -log_level = -log_limit = +error_log = {{PHP_LOG_LOCATION}}/{{PHP_LOG_ERROR_FILE}} +log_level = {{PHP_LOG_LEVEL}} +log_limit = {{PHP_LOG_LIMIT}} [www] -listen = 0.0.0.0: -listen.owner = nginx -listen.group = www-data +listen = 0.0.0.0:{{PHP_FPM_LISTEN_PORT}} +listen.owner = {{NGINX_USER}} +listen.group = {{NGINX_GROUP}} -access.log = / +access.log = {{PHP_LOG_LOCATION}}/{{PHP_LOG_ACCESS_FILE}} -pm = -pm.max_children = -pm.start_servers = -pm.min_spare_servers = -pm.max_spare_servers = +pm = {{PHP_FPM_PROCESS_MANAGER}} +pm.max_children = {{PHP_FPM_MAX_CHILDREN}} +pm.start_servers = {{PHP_FPM_START_SERVERS}} +pm.min_spare_servers = {{PHP_FPM_MIN_SPARE_SERVERS}} +pm.max_spare_servers = {{PHP_FPM_MAX_SPARE_SERVERS}} pm.status_path = /php-fpm_status ping.path = /ping pm.process_idle_timeout = 10s -pm.max_requests = -php_admin_value[log_errors_max_len] = -php_admin_value[max_execution_time] = +pm.max_requests = {{PHP_FPM_MAX_REQUESTS}} +php_admin_value[log_errors_max_len] = {{PHP_LOG_LIMIT}} +php_admin_value[max_execution_time] = {{PHP_TIMEOUT}} php_admin_value[max_input_nesting_level] = 256 php_admin_value[max_input_vars] = 10000 -php_admin_value[memory_limit] = +php_admin_value[memory_limit] = {{PHP_MEMORY_LIMIT}} php_admin_value[openssl.cafile] = /etc/ssl/certs/ca-certificates.crt php_admin_value[openssl.capath] = /etc/ssl/certs -php_admin_value[output_buffering] = -php_admin_value[post_max_size] = -php_admin_value[upload_max_filesize] = -php_flag[display_errors] = +php_admin_value[output_buffering] = {{PHP_FPM_OUTPUT_BUFFER_SIZE}} +php_admin_value[post_max_size] = {{PHP_POST_MAX_SIZE}} +php_admin_value[upload_max_filesize] = {{PHP_UPLOAD_MAX_SIZE}} +php_flag[display_errors] = {{PHP_DISPLAY_ERRORS}} catch_workers_output = yes env[PATH] = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin diff --git a/install/etc/cont-init.d/20-php-fpm b/install/etc/cont-init.d/20-php-fpm index 14d7c36..2271e13 100755 --- a/install/etc/cont-init.d/20-php-fpm +++ b/install/etc/cont-init.d/20-php-fpm @@ -42,8 +42,8 @@ if [ ! -f "/tmp/.container/container-restart" ] ; then phpfpm_configure_extensions phpfpm_configure_authentication phpfpm_configure_logging - if [ "${PHP_FPM_CONTAINER_MODE,,}" != "php-fpm" ] ; then phpfpm_configure_nginx ; fi - if [ "${PHP_FPM_CONTAINER_MODE,,}" != "php-fpm" ] ; then phpfpm_create_default_page ; fi + if [[ "${PHP_FPM_CONTAINER_MODE,,}" == *"nginx"* ]] ; then phpfpm_configure_nginx ; fi + if [[ "${PHP_FPM_CONTAINER_MODE,,}" == *"php-fpm"* ]] ; then phpfpm_create_default_page ; fi if var_true "${NGINX_ENABLE_APPLICATION_CONFIGURATION}"; then phpfpm_configure_site_default ; fi phpfpm_post_init fi diff --git a/install/etc/nginx/snippets/php-fpm.conf b/install/etc/nginx/snippets/php-fpm.conf index a1c311b..790e124 100644 --- a/install/etc/nginx/snippets/php-fpm.conf +++ b/install/etc/nginx/snippets/php-fpm.conf @@ -1,5 +1,5 @@ fastcgi_pass php-fpm-upstream; -fastcgi_read_timeout ; -fastcgi_send_timeout ; +fastcgi_read_timeout {{PHP_TIMEOUT}}; +fastcgi_send_timeout {{PHP_TIMEOUT}}; proxy_http_version 1.1; proxy_set_header Connection "";