Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 14baf98

Browse files
authored
Merge pull request #208 from jdeathe/issue/193
CLOSES #193: Adds php-wrapper and the httpd configuration to implement it.
2 parents bb4c2b7 + c1e95ef commit 14baf98

File tree

4 files changed

+82
-7
lines changed

4 files changed

+82
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Summary of release changes.
1313
- Updates README-short.txt to apply to all image variants.
1414
- Updates Dockerfile `org.deathe.description` metadata LABEL for consistency + include PHP redis module.
1515
- Adds `.env` files to `.gitignore` for exclusion from version control.
16+
- Adds `php-wrapper` and `fcgid.conf` as part of the service; removing dependency on the php-hello-world app.
1617
- Removes unused `DOCKER_PORT_MAP_TCP_22` variable from environment includes.
1718

1819
### 1.12.0 - 2019-04-14

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ ADD src /
2525

2626
# ------------------------------------------------------------------------------
2727
# Provisioning
28-
# - Relocate default fcgid configuration to ensure correct loading order
28+
# - Disable Apache default fcgid configuration; replaced with 00-fcgid.conf
2929
# - Replace placeholders with values in systemd service unit template
3030
# - Set permissions
3131
# ------------------------------------------------------------------------------
32-
RUN cat \
32+
RUN truncate -s 0 \
3333
/etc/httpd/conf.d/fcgid.conf \
34-
> /etc/httpd/conf.d/00-fcgid.conf \
35-
&& truncate -s 0 \
34+
&& chmod 444 \
3635
/etc/httpd/conf.d/fcgid.conf \
3736
&& sed -i \
3837
-e "s~{{RELEASE_VERSION}}~${RELEASE_VERSION}~g" \
@@ -44,9 +43,9 @@ RUN cat \
4443
RUN sed -i \
4544
-e 's~^description =.*$~description = "This CentOS / Apache / PHP-CGI (FastCGI) service is running in a container."~' \
4645
${PACKAGE_PATH}/etc/views/index.ini \
47-
&& sed -r -i \
48-
-e 's~^(source /etc/httpd-bootstrap\.conf)~#\1~' \
49-
${PACKAGE_PATH}/bin/php-wrapper
46+
&& rm -f \
47+
${PACKAGE_PATH}/bin/php-wrapper \
48+
${PACKAGE_PATH}/etc/httpd/conf.d/50-fcgid.conf
5049

5150
# ------------------------------------------------------------------------------
5251
# Set default environment variables used to configure the service container

src/etc/httpd/conf.d/00-fcgid.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<IfModule !fcgid_module>
2+
LoadModule fcgid_module modules/mod_fcgid.so
3+
</IfModule>
4+
5+
<IfModule fcgid_module>
6+
AddHandler fcgid-script php
7+
AddType text/html php
8+
DirectoryIndex index.php
9+
FcgidFixPathinfo 1
10+
FcgidIOTimeout 360
11+
FcgidIPCDir /var/run/mod_fcgid
12+
FcgidIdleTimeout 1800
13+
FcgidMaxProcesses 10
14+
FcgidMaxRequestLen 157286400
15+
FcgidMaxRequestsPerProcess 10000
16+
FcgidPassHeader Authorization
17+
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm
18+
19+
<Directory "${APACHE_CONTENT_ROOT}/${APACHE_PUBLIC_DIRECTORY}">
20+
FcgidWrapper "/var/www/cgi-bin/php-wrapper --tmp=${APACHE_CONTENT_ROOT}/var/tmp" .php
21+
<FilesMatch "\.php$">
22+
Options +ExecCGI
23+
</FilesMatch>
24+
</Directory>
25+
</IfModule>

src/var/www/cgi-bin/php-wrapper

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
function main ()
4+
{
5+
local -r bin="/usr/bin/php-cgi"
6+
local -r nice="/bin/nice"
7+
local -r niceness="15"
8+
9+
local bin_options
10+
local option
11+
local -a options
12+
local tmp="/var/tmp"
13+
14+
while [[ "${#}" -gt 0 ]]
15+
do
16+
case "${1}" in
17+
-d)
18+
options+=("${2}")
19+
shift 2
20+
;;
21+
--tmp=*)
22+
tmp="${1#*=}"
23+
shift 1
24+
;;
25+
esac
26+
done
27+
28+
if [[ ${#options[@]} -gt 0 ]]
29+
then
30+
for option in "${options[@]}"
31+
do
32+
bin_options+=" -d ${option}"
33+
done
34+
fi
35+
36+
export PHP_FCGI_CHILDREN="0"
37+
export PHP_FCGI_MAX_REQUESTS="15000"
38+
export PHPRC="/etc"
39+
export REDIRECT_STATUS="200"
40+
export TMP="${tmp}"
41+
export TEMP="${tmp}"
42+
export TMPDIR="${tmp}"
43+
44+
exec ${nice} \
45+
-n ${niceness} \
46+
${bin} \
47+
${bin_options}
48+
}
49+
50+
main "${@}"

0 commit comments

Comments
 (0)