Skip to content

Commit

Permalink
PHP 5.2 Adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Aug 3, 2018
1 parent 864e503 commit cf21dc3
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 22 deletions.
24 changes: 19 additions & 5 deletions Dockerfiles/base/data/php-fpm.conf/php-fpm-5.2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<section name="pool">

Name of pool. Used in logs and stats.
<value name="name">default</value>
<value name="name">www</value>

Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
Expand All @@ -50,6 +50,16 @@
</value>

Additional php.ini defines, specific to this pool of workers.
<value name="php_defines">
<value name="error_reporting">6135</value>
<value name="xmlrpc_errors">0</value>
<value name="report_memleaks">1</value>
<value name="display_errors">0</value>
<value name="display_startup_errors">0</value>
<value name="track_errors">1</value>
<value name="log_errors">1</value>
<value name="html_errors">0</value>
</value>

Unix user of processes
<value name="user">devilbox</value>
Expand All @@ -68,21 +78,25 @@
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">50</value>
<!--<value name="max_children">50</value>-->
<value name="max_children">5</value>

Settings group for 'apache-like' pm style
<value name="apache_like">
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name="StartServers">4</value>
<!--<value name="StartServers">4</value>-->
<value name="StartServers">3</value>

Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<!--<value name="MinSpareServers">2</value>-->
<value name="MinSpareServers">2</value>

Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MaxSpareServers">6</value>
<!--<value name="MaxSpareServers">6</value>-->
<value name="MaxSpareServers">4</value>
</value>

</value>
Expand All @@ -97,7 +111,7 @@
<value name="request_slowlog_timeout">0s</value>

The log file for slow requests
<value name="slowlog">logs/slow.log</value>
<value name="slowlog">/proc/self/fd/2</value>

Set open file desc rlimit
<value name="rlimit_files">1024</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ copy_fpm_files() {
run "find ${fpm_dst} -type f -iname '*.conf' -exec chmod 0644 \"{}\" \;" "${debug}"
}

###
### Copy php-fpm.conf for PHP 5.2
### Note: PHP 5.2 does not allow includes and comes in XML format,
### we must therefore copy the file to its main file /usr/local/etc/php-fpm.conf
###
copy_fpm_5_2_conf_file() {
local fpm_src="${1}"
local fpm_dst="/usr/local/etc/php-fpm.conf"
local debug="${2}"

if [ -f "${fpm_src}" ]; then
log "info" "PHP-FPM.conf (PHP 5.2): php-fpm.xml -> ${fpm_dst}" "${debug}"
run "cp ${fpm_src} ${fpm_dst}" "${debug}"
fi
}


############################################################
# Sanity Checks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# PHP FPM 5.3 does not allow to pass through environment variables
# PHP FPM 5.2 and PHP-FPM 5.3 do not allow to pass through environment variables
# This is a hacky shell script to create:
# env[NAME]='VALUE' entries for PHP FPM config out of all current env vars

Expand Down
10 changes: 7 additions & 3 deletions Dockerfiles/prod/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ set_timezone "TIMEZONE" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"


###
### PHP-FPM 5.3 Env variables
### PHP-FPM 5.2 and PHP-FPM 5.3 Env variables fix
###
if php -v 2>/dev/null | grep -Eoq '^PHP[[:space:]]5\.3'; then
if php -v 2>/dev/null | grep -Eoq '^PHP[[:space:]]5\.(2|3)'; then
set_env_php_fpm "/usr/local/etc/php-fpm.d/env.conf"
fi

Expand Down Expand Up @@ -159,7 +159,11 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
###
### Copy custom PHP-FPM *.conf files
###
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"
if [ "${PHP_VERSION}" = "5.2" ]; then
copy_fpm_5_2_conf_file "${PHP_CUST_FPM_DIR}/php-fpm.xml" "${DEBUG_LEVEL}"
else
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"
fi


###
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.3
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.4
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.5
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-5.6
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.0
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.1
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.2
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
1 change: 1 addition & 0 deletions Dockerfiles/work/Dockerfile-7.3
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down
8 changes: 6 additions & 2 deletions Dockerfiles/work/data/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ set_timezone "TIMEZONE" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"


###
### PHP-FPM 5.3 Env variables
### PHP-FPM 5.2 and PHP-FPM 5.3 Env variables fix
###
if php -v 2>/dev/null | grep -Eoq '^PHP[[:space:]]5\.3'; then
if php -v 2>/dev/null | grep -Eoq '^PHP[[:space:]]5\.(2|3)'; then
set_env_php_fpm "/usr/local/etc/php-fpm.d/env.conf"
fi

Expand Down Expand Up @@ -159,7 +159,11 @@ copy_ini_files "${PHP_CUST_INI_DIR}" "${PHP_INI_DIR}" "${DEBUG_LEVEL}"
###
### Copy custom PHP-FPM *.conf files
###
if [ "${PHP_VERSION}" = "5.2" ]; then
copy_fpm_5_2_conf_file "${PHP_CUST_FPM_DIR}/php-fpm.xml" "${DEBUG_LEVEL}"
else
copy_fpm_files "${PHP_CUST_FPM_DIR}" "${PHP_FPM_DIR}" "${DEBUG_LEVEL}"
fi


###
Expand Down
24 changes: 19 additions & 5 deletions Dockerfiles/work/data/php-fpm.conf/php-fpm-5.2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<section name="pool">

Name of pool. Used in logs and stats.
<value name="name">default</value>
<value name="name">www</value>

Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
Expand All @@ -50,6 +50,16 @@
</value>

Additional php.ini defines, specific to this pool of workers.
<value name="php_defines">
<value name="error_reporting">-1</value>
<value name="xmlrpc_errors">0</value>
<value name="report_memleaks">1</value>
<value name="display_errors">1</value>
<value name="display_startup_errors">1</value>
<value name="track_errors">1</value>
<value name="log_errors">1</value>
<value name="html_errors">1</value>
</value>

Unix user of processes
<value name="user">devilbox</value>
Expand All @@ -68,21 +78,25 @@
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">50</value>
<!--<value name="max_children">50</value>-->
<value name="max_children">5</value>

Settings group for 'apache-like' pm style
<value name="apache_like">
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name="StartServers">4</value>
<!--<value name="StartServers">4</value>-->
<value name="StartServers">3</value>

Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<!--<value name="MinSpareServers">2</value>-->
<value name="MinSpareServers">2</value>

Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MaxSpareServers">6</value>
<!--<value name="MaxSpareServers">6</value>-->
<value name="MaxSpareServers">4</value>
</value>

</value>
Expand All @@ -97,7 +111,7 @@
<value name="request_slowlog_timeout">0s</value>

The log file for slow requests
<value name="slowlog">logs/slow.log</value>
<value name="slowlog">/proc/self/fd/2</value>

Set open file desc rlimit
<value name="rlimit_files">1024</value>
Expand Down
26 changes: 20 additions & 6 deletions build/ansible/CONFIGURATIONS/php-fpm.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ listen.backlog = {{ item.cfg[item.key].listen_backlog | default(item.cfg[item.al
<section name="pool">

Name of pool. Used in logs and stats.
<value name="name">default</value>
<value name="name">www</value>

Address to accept fastcgi requests on.
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
Expand All @@ -178,6 +178,16 @@ listen.backlog = {{ item.cfg[item.key].listen_backlog | default(item.cfg[item.al
</value>

Additional php.ini defines, specific to this pool of workers.
<value name="php_defines">
<value name="error_reporting">{% if item.key == 'base' %}6135{% else %}-1{% endif %}</value>
<value name="xmlrpc_errors">0</value>
<value name="report_memleaks">1</value>
<value name="display_errors">{% if item.key == 'base' %}0{% else %}1{% endif %}</value>
<value name="display_startup_errors">{% if item.key == 'base' %}0{% else %}1{% endif %}</value>
<value name="track_errors">1</value>
<value name="log_errors">1</value>
<value name="html_errors">{% if item.key == 'base' %}0{% else %}1{% endif %}</value>
</value>

Unix user of processes
<value name="user">{{ item.cfg[item.key].user | default(item.cfg[item.alt].user) }}</value>
Expand All @@ -196,21 +206,25 @@ listen.backlog = {{ item.cfg[item.key].listen_backlog | default(item.cfg[item.al
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value name="max_children">{{ item.cfg[item.key].pm_max_children | default(item.cfg[item.alt].pm_max_children) }}</value>
<!--<value name="max_children">{{ item.cfg[item.key].pm_max_children | default(item.cfg[item.alt].pm_max_children) }}</value>-->
<value name="max_children">5</value>

Settings group for 'apache-like' pm style
<value name="apache_like">
Sets the number of server processes created on startup.
Used only when 'apache-like' pm_style is selected
<value name="StartServers">{{ item.cfg[item.key].pm_start_servers | default(item.cfg[item.alt].pm_start_servers) }}</value>
<!--<value name="StartServers">{{ item.cfg[item.key].pm_start_servers | default(item.cfg[item.alt].pm_start_servers) }}</value>-->
<value name="StartServers">3</value>

Sets the desired minimum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MinSpareServers">{{ item.cfg[item.key].pm_min_spare_servers | default(item.cfg[item.alt].pm_min_spare_servers) }}</value>
<!--<value name="MinSpareServers">{{ item.cfg[item.key].pm_min_spare_servers | default(item.cfg[item.alt].pm_min_spare_servers) }}</value>-->
<value name="MinSpareServers">2</value>

Sets the desired maximum number of idle server processes.
Used only when 'apache-like' pm_style is selected
<value name="MaxSpareServers">{{ item.cfg[item.key].pm_max_spare_servers | default(item.cfg[item.alt].pm_max_spare_servers) }}</value>
<!--<value name="MaxSpareServers">{{ item.cfg[item.key].pm_max_spare_servers | default(item.cfg[item.alt].pm_max_spare_servers) }}</value>-->
<value name="MaxSpareServers">4</value>
</value>

</value>
Expand All @@ -225,7 +239,7 @@ listen.backlog = {{ item.cfg[item.key].listen_backlog | default(item.cfg[item.al
<value name="request_slowlog_timeout">0s</value>

The log file for slow requests
<value name="slowlog">logs/slow.log</value>
<value name="slowlog">{{ item.cfg[item.key].error_log | default(item.cfg[item.alt].error_log) }}</value>

Set open file desc rlimit
<value name="rlimit_files">1024</value>
Expand Down
1 change: 1 addition & 0 deletions build/ansible/DOCKERFILES/Dockerfile-work.j2
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ RUN set -x \
libc-dev \
libffi-dev\
libssl-dev\
libyaml-dev \
make \
mongodb-org-shell \
mongodb-org-tools \
Expand Down

0 comments on commit cf21dc3

Please sign in to comment.