Skip to content

Commit

Permalink
v8.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joseluisq committed Dec 17, 2024
1 parent 1bccf76 commit 6ddaf4a
Show file tree
Hide file tree
Showing 9 changed files with 1,357 additions and 57 deletions.
422 changes: 422 additions & 0 deletions 8.4-fpm/Dockerfile

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions 8.4-fpm/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/sh

set -e

# Check if incomming command contains flags.
if [ "${1#-}" != "$1" ]; then
set -- php-fpm "$@"
fi

# Replace environment variables if `ENV_SUBSTITUTION_ENABLE=true`
if [[ -n "$ENV_SUBSTITUTION_ENABLE" ]] && [[ "$ENV_SUBSTITUTION_ENABLE" = "true" ]]; then
/envsubst.sh
fi

# Disable PHP extensions on demand
extensions=${PHP_DISABLE_EXTENSIONS//[[:blank:]]/}
extensions=${extensions//,/ }
extensions_count=$(echo $extensions | grep -o " " | wc -l)

if [[ -n "$extensions" ]]; then extensions_count=$((extensions_count + 1)); fi

if [[ $extensions_count -gt 0 ]]; then
echo "Disabling $extensions_count extension(s): $(echo $extensions)"

ext_dir=$(php -r 'echo ini_get("extension_dir");')
for ext in $extensions; do
disabled=0

ext_file="$ext_dir/$ext.so"
if [[ -f "$ext_file" ]]; then
mv -f $ext_file "$ext_file.disabled"
disabled=1
fi

ext_file_ini=${PHP_INI_DIR}/conf.d/docker-php-ext-$ext.ini
if [[ -f "$ext_file_ini" ]]; then
mv -f $ext_file_ini "$ext_file_ini.disabled"
disabled=1
fi

if [[ "$disabled" = 1 ]]; then
echo "OK: '$ext' disabled"
fi
done

echo "Verifying PHP extensions..."

php -v
php-fpm --test

PHP_ERROR="$(php -v 2>&1 1>/dev/null)"

if [ -n "${PHP_ERROR}" ]; then
echo "${PHP_ERROR}"
false
fi

PHP_ERROR="$(php -i 2>&1 1>/dev/null)"

if [ -n "${PHP_ERROR}" ]; then
echo "${PHP_ERROR}"
false
fi

PHP_FPM_ERROR="$(php-fpm -v 2>&1 1>/dev/null)"

if [ -n "${PHP_FPM_ERROR}" ]; then
echo "${PHP_FPM_ERROR}"
false
fi

PHP_FPM_ERROR="$(php-fpm -i 2>&1 1>/dev/null)"

if [ -n "${PHP_FPM_ERROR}" ]; then
echo "${PHP_FPM_ERROR}"
false
fi

echo "Tests were successful!"
echo
fi

exec "$@"
45 changes: 45 additions & 0 deletions 8.4-fpm/envsubst.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh

set -e

CWD=/var/data/php-fpm

# 1. PHP-FPM default settings (php-fpm.conf)
XERROR_LOG=/proc/self/fd/2
XLOG_LEVEL=error

if [[ -z "$PHP_FPM_ERROR_LOG" ]]; then export PHP_FPM_ERROR_LOG=$XERROR_LOG; fi
if [[ -z "$PHP_FPM_LOG_LEVEL" ]]; then export PHP_FPM_LOG_LEVEL=$XLOG_LEVEL; fi

envsubst < "$CWD/php-fpm.tmpl.conf" > "/usr/local/etc/php-fpm.conf"

# 2. PHP-FPM WWW Pool (www.conf)
XUSER=www-data
XGROUP=www-data
XLISTEN=9000
XLISTEN_OWNER=$XUSER
XLISTEN_GROUP=$XGROUP

if [[ -z "$PHP_FPM_LISTEN" ]]; then export PHP_FPM_LISTEN=$XLISTEN; fi
if [[ -z "$PHP_FPM_USER" ]]; then export PHP_FPM_USER=$XUSER; fi
if [[ -z "$PHP_FPM_GROUP" ]]; then export PHP_FPM_GROUP=$XGROUP; fi
if [[ -z "$PHP_FPM_LISTEN_OWNER" ]]; then export PHP_FPM_LISTEN_OWNER=$XLISTEN_OWNER; fi
if [[ -z "$PHP_FPM_LISTEN_GROUP" ]]; then export PHP_FPM_LISTEN_GROUP=$XLISTEN_GROUP; fi

envsubst < "$CWD/www.tmpl.conf" > "/usr/local/etc/php-fpm.d/www.conf"

# 3. PHP default settings (default-php.ini)
# 3.1 [PHP]
XMEMORY_LIMIT=512M
XEXPOSE_PHP=On
# 3.2 [Session]
XGC_MAXLIFETIME=1440

if [[ -z "$PHP_MEMORY_LIMIT" ]];
then export PHP_MEMORY_LIMIT=$XMEMORY_LIMIT; fi
if [[ -z "$PHP_EXPOSE_PHP" ]];
then export PHP_EXPOSE_PHP=$XEXPOSE_PHP; fi
if [[ -z "$PHP_SESSION_GC_MAXLIFETIME" ]];
then export PHP_SESSION_GC_MAXLIFETIME=$XGC_MAXLIFETIME; fi

envsubst < "$CWD/default-php.tmpl.ini" > "${PHP_INI_DIR}/conf.d/default-php.ini"
44 changes: 44 additions & 0 deletions 8.4-fpm/extensions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
amqp
apcu
bcmath
bz2
exif
gd
gettext
gmp
igbinary
imap
intl
lz4
memcache
mongodb
msgpack
mysqli
oauth
opcache
pcntl
pdo_dblib
pdo_mysql
pdo_pgsql
pdo_sqlsrv
pgsql
psr
rdkafka
redis
soap
sockets
sodium
sqlsrv
ssh2
swoole
sysvmsg
sysvsem
sysvshm
tidy
uuid
vips
xdebug
xsl
yaml
zip
zstd
145 changes: 145 additions & 0 deletions 8.4-fpm/php-fpm.tmpl.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/local). This prefix can be dynamically changed by using the
; '-p' argument from the command line.

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /usr/local/var
; Default Value: none
;pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; into a local file.
; Note: the default prefix is /usr/local/var
; Default Value: log/php-fpm.log
; For Docker: /proc/self/fd/2
error_log = $PHP_FPM_ERROR_LOG

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = $PHP_FPM_LOG_LEVEL

; Log limit on number of characters in the single line (log entry). If the
; line is over the limit, it is wrapped on multiple lines. The limit is for
; all logged characters including message prefix and suffix if present. However
; the new line character does not count into it as it is present only when
; logging to a file descriptor. It means the new line character is not present
; when logging to syslog.
; Default Value: 1024
; https://github.com/docker-library/php/pull/725#issuecomment-443540114
log_limit = 8192

; Log buffering specifies if the log line is buffered which means that the
; line is written in a single write operation. If the value is false, then the
; data is written directly into the file descriptor. It is an experimental
; option that can potentionaly improve logging performance and memory usage
; for some heavy logging scenarios. This option is ignored if logging to syslog
; as it has to be always buffered.
; Default value: yes
;log_buffering = no

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated. This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 0

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 0

; The maximum number of processes FPM will fork. This has been designed to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lowest priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless specified otherwise
; Default Value: no set
; process.priority = -19

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
daemonize = no

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is built with systemd integration, specify the interval,
; in seconds, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ;
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options. The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
; - the global prefix if it's been set (-p argument)
; - /usr/local otherwise
include = /usr/local/etc/php-fpm.d/*.conf
57 changes: 57 additions & 0 deletions 8.4-fpm/php.tmpl.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[PHP]

; Memory
; Note: "memory_limit" should be larger than "post_max_size"
memory_limit = $PHP_MEMORY_LIMIT


; Timeouts
max_execution_time = 120
max_input_time = 120


; Uploads
; Note: "post_max_size" should be greater than "upload_max_filesize"
post_max_size = 72M
upload_max_filesize = 64M
max_file_uploads = 20


; Vars
variables_order = EGPCS
max_input_vars = 8000
max_input_nesting_level = 64


; Error reporting
; Note: error_log is dynamic and handled during start to set appropriate setting
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
xmlrpc_errors = Off
report_memleaks = On
display_errors = Off
display_startup_errors = Off
log_errors = On
html_errors = Off


; Xdebug settings
xdebug.default_enable = Off
xdebug.profiler_enable = Off
xdebug.remote_enable = Off
xdebug.remote_autostart = Off

;
; Misc
;
; Decides whether PHP may expose the fact that it is installed on the server
; (e.g. by adding its signature to the Web server header). It is no security
; threat in any way, but it makes it possible to determine whether you use PHP
; on your server or not.
; Default: On
expose_php = $PHP_EXPOSE_PHP

[Session]
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
; http://php.net/session.gc-maxlifetime
session.gc_maxlifetime = $PHP_SESSION_GC_MAXLIFETIME
Loading

0 comments on commit 6ddaf4a

Please sign in to comment.