From 7e4c0e239e6f258b6982ee5eb1c175206f879ae7 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Fri, 19 Jul 2019 20:17:27 +0100 Subject: [PATCH 1/2] #173: Adds php-wrapper and the httpd configuration to implement it. --- CHANGELOG.md | 1 + Dockerfile | 3 ++ src/etc/httpd/conf.d/00-fcgid.conf | 19 +++++++++++ src/var/www/cgi-bin/php-wrapper | 53 ++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) create mode 100644 src/etc/httpd/conf.d/00-fcgid.conf create mode 100755 src/var/www/cgi-bin/php-wrapper diff --git a/CHANGELOG.md b/CHANGELOG.md index a6e6b1f..34df6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Summary of release changes. - Adds `SYSTEM_TIMEZONE` handling to Makefile, scmi, systemd unit and docker-compose templates. - Adds system time zone validation to healthcheck. - Adds lock/state file to bootstrap/wrapper scripts. +- Adds `php-wrapper` and `fcgid.conf` as part of the service; removing dependency on the php-hello-world app. - Removes unused `DOCKER_PORT_MAP_TCP_22` variable from environment includes. - Removes support for long image tags (i.e. centos-7-2.x.x). - Removes `APACHE_AUTOSTART_HTTPD_BOOTSTRAP`, replaced with `ENABLE_HTTPD_BOOTSTRAP`. diff --git a/Dockerfile b/Dockerfile index 1c56ebc..4c7892b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -206,6 +206,9 @@ RUN mkdir -p -m 750 ${PACKAGE_PATH} \ && mv \ ${PACKAGE_PATH}/public \ ${PACKAGE_PATH}/public_html \ + && rm -f \ + ${PACKAGE_PATH}/bin/php-wrapper \ + ${PACKAGE_PATH}/etc/httpd/conf.d/50-fcgid.conf \ && $(\ if [[ -f /usr/share/php-pecl-apc/apc.php ]]; then \ cp \ diff --git a/src/etc/httpd/conf.d/00-fcgid.conf b/src/etc/httpd/conf.d/00-fcgid.conf new file mode 100644 index 0000000..2cb8e21 --- /dev/null +++ b/src/etc/httpd/conf.d/00-fcgid.conf @@ -0,0 +1,19 @@ + + AddHandler fcgid-script php + AddType text/html php + DirectoryIndex index.php + FcgidFixPathinfo 1 + FcgidIOTimeout 360 + FcgidIdleTimeout 1800 + FcgidMaxProcesses 10 + FcgidMaxRequestLen 157286400 + FcgidMaxRequestsPerProcess 10000 + FcgidPassHeader Authorization + + + FcgidWrapper "/var/www/cgi-bin/php-wrapper --tmp=${APACHE_CONTENT_ROOT}/var/tmp" .php + + Options +ExecCGI + + + diff --git a/src/var/www/cgi-bin/php-wrapper b/src/var/www/cgi-bin/php-wrapper new file mode 100755 index 0000000..df87697 --- /dev/null +++ b/src/var/www/cgi-bin/php-wrapper @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +function main () +{ + local -r bin="/usr/bin/php-cgi" + local -r nice="/bin/nice" + local -r niceness="15" + + local bin_options + local option + local -a options + local tmp="/var/tmp" + + # Parse options + while [[ "${#}" -gt 0 ]] + do + case "${1}" in + -d) + options+=("${2}") + shift 2 + ;; + --tmp=*) + tmp="${1#*=}" + shift 1 + ;; + esac + done + + if [[ ${#options[@]} -gt 0 ]] + then + for option in "${options[@]}" + do + bin_options+=" -d ${option}" + done + fi + + # PHP child process management should always be disabled with mod_fcgid + export PHP_FCGI_CHILDREN="0" + export PHP_FCGI_MAX_REQUESTS="15000" + export PHPRC="/etc" + export REDIRECT_STATUS="200" + export TMP="${tmp}" + export TEMP="${tmp}" + export TMPDIR="${tmp}" + + # FastCGI-enabled PHP executable + exec ${nice} \ + -n ${niceness} \ + ${bin} \ + ${bin_options} +} + +main "${@}" From 04747ff282c45a77913225c4a4658187650e8246 Mon Sep 17 00:00:00 2001 From: James Deathe Date: Fri, 19 Jul 2019 20:21:37 +0100 Subject: [PATCH 2/2] #173: Remove unnecessary comments. --- src/var/www/cgi-bin/php-wrapper | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/var/www/cgi-bin/php-wrapper b/src/var/www/cgi-bin/php-wrapper index df87697..7c78ed7 100755 --- a/src/var/www/cgi-bin/php-wrapper +++ b/src/var/www/cgi-bin/php-wrapper @@ -11,7 +11,6 @@ function main () local -a options local tmp="/var/tmp" - # Parse options while [[ "${#}" -gt 0 ]] do case "${1}" in @@ -34,7 +33,6 @@ function main () done fi - # PHP child process management should always be disabled with mod_fcgid export PHP_FCGI_CHILDREN="0" export PHP_FCGI_MAX_REQUESTS="15000" export PHPRC="/etc" @@ -43,7 +41,6 @@ function main () export TEMP="${tmp}" export TMPDIR="${tmp}" - # FastCGI-enabled PHP executable exec ${nice} \ -n ${niceness} \ ${bin} \