Skip to content

Commit

Permalink
Merge branch 'issue-190'
Browse files Browse the repository at this point in the history
  • Loading branch information
capile committed Dec 2, 2024
2 parents 848c180 + 1c592bd commit e6e3de7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export FASTCGI_READ_TIMEOUT=${FASTCGI_READ_TIMEOUT:-300s}
export FASTCGI_SEND_TIMEOUT=${FASTCGI_SEND_TIMEOUT:-300s}
export FASTCGI_CONNECT_TIMEOUT=${FASTCGI_CONNECT_TIMEOUT:-300s}

export PHP_FCGI_CHILDREN=${PHP_FCGI_CHILDREN:-5}
export PHP_FCGI_START_SERVERS=${PHP_FCGI_START_SERVERS:-2}
export PHP_FCGI_SPARE_SERVERS=${PHP_FCGI_SPARE_SERVERS:-1}
export PHP_FCGI_MAX_REQUESTS=${PHP_FCGI_MAX_REQUESTS:-0}

export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-2048M}
export PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME:-300}
export PHP_UPLOAD_MAX_FILESIZE=${PHP_UPLOAD_MAX_FILESIZE:-50M}
Expand Down
29 changes: 29 additions & 0 deletions core/files/entrypoint_fpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,35 @@ change_php_vars() {
sed -i "s/session.sid_length = .*/session.sid_length = 64/" "$FILE"
sed -i "s/session.use_strict_mode = .*/session.use_strict_mode = 1/" "$FILE"
done

for FILE in /etc/php/*/fpm/pool.d/www.conf
do
[[ -e $FILE ]] || break
echo "Configure PHP | Setting 'pm.max_children = ${PHP_FCGI_CHILDREN}'"
sed -i -E "s/;?pm.max_children = .*/pm.max_children = ${PHP_FCGI_CHILDREN}/" "$FILE"
echo "Configure PHP | Setting 'pm.start_servers = ${PHP_FCGI_START_SERVERS}'"
sed -i -E "s/;?pm.start_servers = .*/pm.start_servers = ${PHP_FCGI_START_SERVERS}/" "$FILE"
echo "Configure PHP | Setting 'pm.(min|max)_spare_servers = ${PHP_FCGI_START_SERVERS}'"
sed -i -E "s/;?pm.min_spare_servers = .*/pm.min_spare_servers = ${PHP_FCGI_SPARE_SERVERS}/" "$FILE"
if [[ "$PHP_FCGI_START_SERVERS" -gt "$PHP_FCGI_SPARE_SERVERS" ]]; then
sed -i -E "s/;?pm.max_spare_servers = .*/pm.max_spare_servers = ${PHP_FCGI_START_SERVERS}/" "$FILE"
else
sed -i -E "s/;?pm.max_spare_servers = .*/pm.max_spare_servers = ${PHP_FCGI_SPARE_SERVERS}/" "$FILE"
fi
echo "Configure PHP | Setting 'pm.max_requests = ${PHP_FCGI_MAX_REQUESTS}'"
sed -i -E "s/;?pm.max_requests = .*/pm.max_requests = ${PHP_FCGI_MAX_REQUESTS}/" "$FILE"
if [[ "$FASTCGI_STATUS_LISTEN" != "" ]]; then
echo "Configure PHP | Setting 'pm.status_path = /status'"
sed -i -E "s/;?pm.status_path = .*/pm.status_path = \/status/" "$FILE"
echo "Configure PHP | Setting 'pm.status_path = /run/php/php-fpm-status.sock'"
sed -i -E "s/;?pm.status_listen = .*/pm.status_listen = \/run\/php\/php-fpm-status.sock/" "$FILE"
else
echo "Configure PHP | Disabling 'pm.status_path'"
sed -i -E "s/^pm.status_path = /;pm.status_path = /" "$FILE"
echo "Configure PHP | Disabling 'pm.status_listen'"
sed -i -E "s/^pm.status_listen =/;pm.status_listen =/" "$FILE"
fi
done
}

echo "Configure PHP | Change PHP values ..." && change_php_vars
Expand Down
9 changes: 9 additions & 0 deletions core/files/entrypoint_nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ init_nginx() {
echo "... DH parameters found"
fi
if [[ "$FASTCGI_STATUS_LISTEN" != "" ]]; then
echo "... enabling php-fpm status page"
ln -s /etc/nginx/sites-available/php-fpm-status /etc/nginx/sites-enabled/php-fpm-status
sed -i -E "s/ listen [^;]+/ listen $FASTCGI_STATUS_LISTEN" /etc/nginx/sites-enabled/php-fpm-status
elif [[ -f /etc/nginx/sites-enabled/php-fpm-status ]]; then
echo "... disabling php-fpm status page"
rm /etc/nginx/sites-enabled/php-fpm-status
fi
flip_nginx false false
}
Expand Down
8 changes: 8 additions & 0 deletions core/files/etc/nginx/sites-available/php-fpm-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server {
listen 8999;
location ~ ^/status$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/run/php/php-fpm-status.sock;
}
}
16 changes: 15 additions & 1 deletion template.env
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ SYNCSERVERS_1_PULL_RULES=
# 2 - Debug on + SQL dump
# DEBUG=

# FastCGI configuration
# FastCGI configuration on nginx
# FASTCGI_READ_TIMEOUT=300s
# FASTCGI_SEND_TIMEOUT=300s
# FASTCGI_CONNECT_TIMEOUT=300s
# Whete to listen to PHP-FPM status. Can be a port or a ip:port. If not set the status page will not be shown.
# Do not expose this page in public networks.
# FASTCGI_STATUS_LISTEN=""

# PHP FPM configuration

Expand All @@ -198,6 +201,17 @@ SYNCSERVERS_1_PULL_RULES=
# Maximum time PHP spends parsing input data in seconds.
# PHP_MAX_INPUT_TIME=300

## PHP FPM pool setup
# Maximum number of php-fpm processes, limits the number of simultaneous requests.
PHP_FCGI_CHILDREN="5"
# Number of processes created on startup.
PHP_FCGI_START_SERVERS="2"
# The desired number of idle server processes.
PHP_FCGI_SPARE_SERVERS="1"
# The number of requests each process should execute before respawning. "0" means endless request processing.
PHP_FCGI_MAX_REQUESTS="0"


## Additional PHP settings
# Timeout (in minutes) for user session inactivity before it expires.
# PHP_SESSION_TIMEOUT=60
Expand Down

0 comments on commit e6e3de7

Please sign in to comment.