@@ -104,22 +104,19 @@ phpfpm_configure_nginx() {
104104
105105phpfpm_configure_nginx_php() {
106106 local nginxphpconf_value
107- if [ -v NGINX_${site^^}_PHP_UPSTREAM ] ; then
107+ if [ -v NGINX_${site^^}_PHP_UPSTREAM ]; then
108108 nginxphpconf_value="$(set -o posix ; set | grep "NGINX_${site^^}_PHP_UPSTREAM=" | cut -d = -f 2)"
109109 else
110- if [ -n "${PHPFPM_POOL_WWW_LISTEN_TYPE}" ]; then
111- nginxphpconf_value=www
112- ln -sf /etc/nginx/snippets/server.available/php-fpm/www.conf /etc/nginx/snippets/server.available/php-fpm.conf
113- else
114- nginxphpconf_value="$(set -o posix ; set | sort | grep "^PHPFPM_POOL_.*" | sed -n "s/^PHPFPM_POOL_\([^_]*\)_.*$/\1/p" | sed -e "/^DEFAULT/d" | uniq)"
115- ln -sf /etc/nginx/snippets/server.available/php-fpm/${nginxphpconf_value}.conf /etc/nginx/snippets/server.available/php-fpm.conf
110+ nginxphpconf_value=www
116111 fi
112+ ln -sf /etc/nginx/snippets/server.available/php-fpm/${nginxphpconf_value}.conf /etc/nginx/snippets/server.available/php-fpm.conf
117113
118114 if [ -f "${site_path}" ] && [ -f /etc/nginx/snippets/server.available/php-fpm/"${nginxphpconf_value}".conf ]; then
119115 sed -i \
120116 -e "s|include /etc/nginx/snippets/server.available/php-fpm.*;|include /etc/nginx/snippets/server.available/php-fpm/${nginxphpconf_value}.conf;|g" \
121- "${site_path}"
122- fi
117+ "${site_path}"
118+ PHP_UPSTREAM=${nginxphpconf_value}
119+ update_template "${site_path}" PHP_UPSTREAM
123120 fi
124121}
125122
@@ -165,15 +162,12 @@ EOF
165162 echo " server ${_php_fpm_upstream_host_socket_prefix}${_php_fpm_upstream} $(set -o posix ; set | grep -oE "^PHPFPM_UPSTREAM_${1^^}_OPTIONS=" | cut -d = -f2-);" | silent tee -a /etc/nginx/snippets/upstream.available/upstream-phpfpm-${1,,}.conf
166163 done
167164 echo "}" | silent tee -a /etc/nginx/snippets/upstream.available/upstream-phpfpm-${1,,}.conf
168- set +x
169165 sed -i \
170166 -e "/# Do not delete - Upstream Configuration/a\ \ \ \ include \/etc\/nginx\/snippets\/upstream.available\/upstream-phpfpm-${1,,}.conf;" \
171167 -e "/# Do not delete - Upstream Configuration/a\ \ \ \ ### PHP-FPM Multiple Handlers configuration" \
172168 /etc/nginx/nginx.conf
173- set +x
174169}
175170
176-
177171phpfpm_configure_pools() {
178172 local _phpfpm_pools
179173 local _phpfpm_pool_vars
@@ -191,6 +185,7 @@ phpfpm_configure_pools() {
191185
192186 if [ "$(set -o posix ; set | sort | grep "^PHPFPM_POOL_.*" | sed -n "s/^PHPFPM_POOL_\([^_]*\)_.*$/\1/p" | uniq | wc -l)" -eq 1 ] ; then
193187 export PHPFPM_POOL_WWW_LISTEN_TYPE="${PHPFPM_POOL_DEFAULT_LISTEN_TYPE}"
188+ ## TODO - need to find a way to dynamically set this in nginx /sites.enabled or other file - NGINX_SITE_... PHPFPM_POOL_NGINX_SITE?
194189 fi
195190
196191 for phpfpm_pool in $(set -o posix ; set | sort | grep "^PHPFPM_POOL_.*_LISTEN_TYPE" | sed -n "s/^PHPFPM_POOL_\([^_]*\)_.*$/\1/p" | sed "/^DEFAULT/d" ) ; do
@@ -398,7 +393,7 @@ phpfpm_configure_site_default() {
398393
399394 ### Populate your custom directives here
400395 location ~ \.php(/|\$) {
401- include /etc/nginx/snippets/server.available/php-fpm.conf;
396+ include /etc/nginx/snippets/server.available/php-fpm/${PHP_UPSTREAM} .conf;
402397 fastcgi_split_path_info ^(.+?\.php)(/.+)\$;
403398 fastcgi_param PATH_INFO \$fastcgi_path_info;
404399 fastcgi_index index.php;
0 commit comments