Skip to content

Commit

Permalink
Merge pull request #42 from druidfi/php-conf-changes
Browse files Browse the repository at this point in the history
PHP conf changes
  • Loading branch information
back-2-95 authored Apr 22, 2024
2 parents 5bf8a00 + ed35d83 commit fe8bd14
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 28 deletions.
6 changes: 3 additions & 3 deletions php/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ apk --no-cache add php81-fpm
ln -sfn /usr/sbin/php-fpm81 /usr/sbin/php-fpm
EOF

COPY files/etc/php/php-fpm.d/www.conf /etc/php81/php-fpm.d/www.conf
COPY files/etc/php/php-fpm.d/www.conf.ep /etc/php81/php-fpm.d/www.conf.ep

FROM final-php as build-php-fpm-82

Expand All @@ -158,7 +158,7 @@ apk --no-cache add php82-fpm
ln -sfn /usr/sbin/php-fpm82 /usr/sbin/php-fpm
EOF

COPY files/etc/php/php-fpm.d/www.conf /etc/php82/php-fpm.d/www.conf
COPY files/etc/php/php-fpm.d/www.conf.ep /etc/php82/php-fpm.d/www.conf.ep

FROM final-php as build-php-fpm-83

Expand All @@ -167,7 +167,7 @@ apk --no-cache add php83-fpm
ln -sfn /usr/sbin/php-fpm83 /usr/sbin/php-fpm
EOF

COPY files/etc/php/php-fpm.d/www.conf /etc/php83/php-fpm.d/www.conf
COPY files/etc/php/php-fpm.d/www.conf.ep /etc/php83/php-fpm.d/www.conf.ep

#
# Final PHP-FPM
Expand Down
6 changes: 3 additions & 3 deletions php/files/entrypoints/10-ssh-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ do
SOCKET="/tmp/${i}_ssh-agent/socket"

if [ -S "${SOCKET}" ]; then
echo "Found socket from ${SOCKET}"
echo "Symlink ${SSH_AUTH_SOCK} to ${SOCKET}..."
echo "- Found socket from ${SOCKET}"
echo "- Symlink ${SSH_AUTH_SOCK} to ${SOCKET}..."
ln -sf "${SOCKET}" "$SSH_AUTH_SOCK"
SOCKET_FOUND=1
fi
done

if [ ${SOCKET_FOUND} = 0 ]; then
echo "No socket found"
echo "- No socket found"
fi
8 changes: 4 additions & 4 deletions php/files/entrypoints/15-xdebug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
XDEBUG_INI=/etc/php$PHP_INSTALL_VERSION/conf.d/xdebug.ini

if [ "$XDEBUG_ENABLE" = "true" ]; then
echo "Start with Xdebug enabled. Remove XDEBUG_ENABLE=true ENV variable to disable it."
echo "- Start with Xdebug enabled. Remove XDEBUG_ENABLE=true ENV variable to disable it."
if [ -f "$XDEBUG_INI" ]; then
echo "Already enabled..."
echo "- Already enabled..."
else
sudo mv "$XDEBUG_INI".disabled "$XDEBUG_INI"
fi
else
echo "Start with Xdebug disabled. Add XDEBUG_ENABLE=true ENV variable to enable it."
echo "- Start with Xdebug disabled. Add XDEBUG_ENABLE=true ENV variable to enable it."
if [ -f "$XDEBUG_INI" ]; then
sudo mv "$XDEBUG_INI" "$XDEBUG_INI".disabled
else
echo "Already disabled..."
echo "- Already disabled..."
fi
fi
12 changes: 10 additions & 2 deletions php/files/entrypoints/19-php_ini.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/bash

EP="sudo --preserve-env ep"; [ "$APP_ENV" = "dev" ] && EP+=" -v"
TEMPLATE=/etc/php$PHP_INSTALL_VERSION/conf.d/99_dynamic.ini.ep
TARGET=/etc/php$PHP_INSTALL_VERSION/conf.d/99_dynamic.ini

if [ -f "$TEMPLATE" ]; then
echo "Prepare PHP 99_custom.ini conf..."
echo "- Prepare PHP 99_custom.ini conf..."

sudo --preserve-env ep -v "$TEMPLATE"
$EP "$TEMPLATE"
sudo mv "$TEMPLATE" "$TARGET"
fi

if [ $APP_ENV = 'prod' ]; then
echo "- Enable 99_production.ini..."
sudo mv \
/etc/php$PHP_INSTALL_VERSION/conf.d/99_production.ini.dist \
/etc/php$PHP_INSTALL_VERSION/conf.d/99_production.ini
fi
11 changes: 11 additions & 0 deletions php/files/entrypoints/20-php-fpm.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/bin/bash

EP="sudo --preserve-env ep"; [ "$APP_ENV" = "dev" ] && EP+=" -v"
TEMPLATE=/etc/php$PHP_INSTALL_VERSION/php-fpm.d/www.conf.ep
TARGET=/etc/php$PHP_INSTALL_VERSION/php-fpm.d/www.conf

if [ -f "$TEMPLATE" ]; then
echo "- Prepare PHP-FPM www.conf file..."

$EP "$TEMPLATE"
sudo mv "$TEMPLATE" "$TARGET"
fi

echo "Start up PHP-FPM..."

sudo -E LD_PRELOAD=/usr/lib/preloadable_libiconv.so php-fpm -F -R &
Expand Down
5 changes: 3 additions & 2 deletions php/files/entrypoints/30-nginx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

echo "Prepare Nginx conf..."
echo "- Prepare Nginx conf..."

sudo --preserve-env ep -v /etc/nginx/conf.d/default.conf
EP="sudo --preserve-env ep"; [ "$APP_ENV" = "dev" ] && EP+=" -v"
$EP /etc/nginx/conf.d/default.conf
20 changes: 17 additions & 3 deletions php/files/etc/php/conf.d/98_custom.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
[PHP]
expose_php=Off
memory_limit=512M

[Date]
date.timezone="Europe/Helsinki"

# Default value 128
opcache.memory_consumption=512
# Default value 8
opcache.interned_strings_buffer=64
# Default value 10000
opcache.max_accelerated_files=30000
# Default value 0
opcache.enable_file_override=1
# Default value 1
opcache.validate_timestamps=1
# Default value 4096K
realpath_cache_size=8M
# Default value 32M
apc.shm_size=64M
# Default value 30
max_execution_time=180
1 change: 0 additions & 1 deletion php/files/etc/php/conf.d/99_dynamic.ini.ep
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[PHP]
memory_limit=${PHP_MEMORY_LIMIT:-512M}
post_max_size=${PHP_POST_MAX_SIZE:-32M}
sendmail_path=${PHP_SENDMAIL_PATH:-/usr/sbin/sendmail -t -i}
Expand Down
1 change: 1 addition & 0 deletions php/files/etc/php/conf.d/99_production.ini.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
opcache.validate_timestamps=0
1 change: 0 additions & 1 deletion php/files/etc/php/conf.d/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[xdebug]
zend_extension=xdebug.so

xdebug.mode=debug
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ listen = [::]:9000
clear_env = no

pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.max_requests = 500
pm.max_children = ${PHP_FPM_PM_MAX_CHILDREN:-8}
pm.start_servers = ${PHP_FPM_PM_START_SERVERS:-2}
pm.min_spare_servers = ${PHP_FPM_PM_MIN_SPARE_SERVERS:-1}
pm.max_spare_servers = ${PHP_FPM_PM_MAX_SPARE_SERVERS:-3}
pm.max_requests = ${PHP_FPM_PM_MAX_REQUESTS:-500}

user=www-data
group=www-data
Expand All @@ -24,9 +24,6 @@ group=www-data
catch_workers_output = yes

; Remove the 'child 10 said into stderr' prefix in the log and only show the actual message
; decorate_workers_output = no
decorate_workers_output = no

php_value[memory_limit] = 512M

pm.status_path = /status
ping.path = /ping

0 comments on commit fe8bd14

Please sign in to comment.