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..7c78ed7 --- /dev/null +++ b/src/var/www/cgi-bin/php-wrapper @@ -0,0 +1,50 @@ +#!/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" + + 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 + + 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}" + + exec ${nice} \ + -n ${niceness} \ + ${bin} \ + ${bin_options} +} + +main "${@}"