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

Commit abec596

Browse files
committed
Merge pull request #24 from jdeathe/issue/23
ISSUE 23: Relocated php-wrapper to be outside the app home directory
2 parents c6f3a52 + 2304912 commit abec596

File tree

3 files changed

+28
-45
lines changed

3 files changed

+28
-45
lines changed

Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,8 @@ RUN mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.off \
5151
# -----------------------------------------------------------------------------
5252
# Add the PHP Wrapper script
5353
# -----------------------------------------------------------------------------
54-
RUN mkdir -p /var/www/app/bin
55-
ADD var/www/app/bin/php-wrapper /var/www/app/bin/
56-
57-
# -----------------------------------------------------------------------------
58-
# Set permissions & add to the template directory
59-
# -----------------------------------------------------------------------------
60-
RUN chmod -R 750 /var/www/app/bin \
61-
&& cp -rpf /var/www/app/bin /var/www/.app-skel/bin
54+
ADD var/www/app-bin/php-wrapper /var/www/app-bin/
55+
RUN chmod -R 750 /var/www/app-bin
6256

6357
# -----------------------------------------------------------------------------
6458
# Copy files into place

etc/apache-bootstrap

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,12 @@ fi
2424
if [[ ! -n $(find ${APP_HOME_DIR} -maxdepth 1 -type f) ]] && [[ -d ${APP_HOME_DIR_TEMPLATE} ]]; then
2525
echo Home directory ${APP_HOME_DIR} exists but is empty - populate it using ${APP_HOME_DIR_TEMPLATE}...
2626
cp -rf ${APP_HOME_DIR_TEMPLATE}/. ${APP_HOME_DIR}/
27-
elif [[ ! -d ${APP_HOME_DIR}/bin || ! -n $(find ${APP_HOME_DIR}/bin -maxdepth 1 -type f) ]] && [[ -d ${APP_HOME_DIR_TEMPLATE}/bin ]]; then
28-
echo Home directory ${APP_HOME_DIR}/bin is missing or empty empty - populate it using ${APP_HOME_DIR_TEMPLATE}/bin...
29-
cp -rf ${APP_HOME_DIR_TEMPLATE}/bin ${APP_HOME_DIR}/
30-
elif [[ ! -d ${APP_HOME_DIR}/public_html ]]; then
31-
echo ERROR: ${APP_HOME_DIR}/public_html not found.
32-
exit 1
3327
fi
3428

35-
# Correct permissions (750) must be set on the bin directory and the php-wrapper
36-
if [[ ! "$(stat -c %a ${APP_HOME_DIR}/bin)" == "750" ]]; then
37-
echo ERROR: Permissions on ${APP_HOME_DIR}/bin must be 750...
38-
# exit 1
39-
elif [[ ! "$(stat -c %a ${APP_HOME_DIR}/bin/php-wrapper)" == "750" ]]; then
40-
echo ERROR: Permissions on ${APP_HOME_DIR}/bin/php-wrapper must be 750...
41-
# exit 1
29+
# Document root directory is required
30+
if [[ ! -d ${APP_HOME_DIR}/public_html ]]; then
31+
echo ERROR: ${APP_HOME_DIR}/public_html not found.
32+
exit 1
4233
fi
4334

4435
# If users need to change the vhost.conf the SSL version can be rebuilt if it is deleted
@@ -100,17 +91,23 @@ fi
10091

10192
# Set the Apache (run) service user/group
10293
if [[ ${OPTS_SUEXECUSERGROUP} == "true" ]]; then
103-
sed -i -e "s~^User .*$~User ${OPTS_SERVICE_USER_GROUP}~g" -e "s~^Group .*$~Group ${OPTS_SERVICE_USER_GROUP}~g" -e "s~^LogLevel warn$~LogLevel debug~g" /etc/httpd/conf/httpd.conf
94+
sed -i -e "s~^User .*$~User ${OPTS_SERVICE_USER_GROUP}~g" \
95+
-e "s~^Group .*$~Group ${OPTS_SERVICE_USER_GROUP}~g" /etc/httpd/conf/httpd.conf
10496
sed -i -e 's~#SuexecUserGroup \(.*\)$~SuexecUserGroup \1~g' ${APP_HOME_DIR}/vhost.conf
10597
sed -i -e 's~#SuexecUserGroup \(.*\)$~SuexecUserGroup \1~g' ${APP_HOME_DIR}/vhost-ssl.conf
106-
chown -R 502:502 /var/{www/app/bin,www/.app-skel/bin,run/mod_fcgid}
98+
chown -R 502:502 /var/{www/app-bin,run/mod_fcgid}
10799
else
108-
sed -i -e "s~^User .*$~User apache~g" -e "s~^Group .*$~Group apache~g" /etc/httpd/conf/httpd.conf
100+
sed -i -e "s~^User .*$~User apache~g" \
101+
-e "s~^Group .*$~Group apache~g" /etc/httpd/conf/httpd.conf
109102
sed -i -e 's~\([^#]\)SuexecUserGroup \(.*\)$~\1#SuexecUserGroup \2~g' ${APP_HOME_DIR}/vhost.conf
110103
sed -i -e 's~\([^#]\)SuexecUserGroup \(.*\)$~\1#SuexecUserGroup \2~g' ${APP_HOME_DIR}/vhost-ssl.conf
111-
chown -R apache:apache /var/{www/app/bin,www/.app-skel/bin,run/mod_fcgid}
104+
chown -R apache:apache /var/{www/app-bin,run/mod_fcgid}
112105
fi
113106

107+
# Update any existing instances of php-wrapper path in the Virtual Host
108+
sed -i -e 's~app/bin/php-wrapper~app-bin/php-wrapper~g' ${APP_HOME_DIR}/vhost.conf
109+
sed -i -e 's~app/bin/php-wrapper~app-bin/php-wrapper~g' ${APP_HOME_DIR}/vhost-ssl.conf
110+
114111
echo Loading Apache modules...
115112
for MODULE in ${APACHE_LOAD_MODULES}
116113
do
@@ -124,16 +121,15 @@ done
124121
echo "${OPTS_SERVICE_USER}:${OPTS_SERVICE_USER_PASSWORD}" | chpasswd
125122
echo "${OPTS_SERVICE_USER_GROUP}:${OPTS_SERVICE_USER_GROUP_PASSWORD}" | chpasswd
126123

127-
echo
128-
echo "================================================================================"
129-
echo "Apache Credentials"
130-
echo "--------------------------------------------------------------------------------"
131-
echo "${OPTS_SERVICE_USER} : ${OPTS_SERVICE_USER_PASSWORD}"
132-
echo "${OPTS_SERVICE_USER_GROUP} : ${OPTS_SERVICE_USER_GROUP_PASSWORD}"
133-
echo "--------------------------------------------------------------------------------"
134-
echo
135-
136-
# Allow some time for supervisor_stdout to start
137-
sleep 2
124+
cat <<-EOT
125+
126+
================================================================================
127+
Apache Credentials
128+
--------------------------------------------------------------------------------
129+
${OPTS_SERVICE_USER} : ${OPTS_SERVICE_USER_PASSWORD}
130+
${OPTS_SERVICE_USER_GROUP} : ${OPTS_SERVICE_USER_GROUP_PASSWORD}
131+
--------------------------------------------------------------------------------
132+
133+
EOT
138134

139135
exit 0

var/www/app/bin/php-wrapper renamed to var/www/app-bin/php-wrapper

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
source /etc/apache-bootstrap.conf
4+
35
# Allow PHP settings to be varied by passing a parameter to php-wrapper
46
PHP_VERSION=$1
57
PHP_WRAPPER_MODE=$2
@@ -46,15 +48,6 @@ else
4648
X_PHP_CGI="/usr/bin/php-cgi"
4749
fi
4850

49-
# Set the app home directory relative to the wrapper script
50-
ROOT_WWW_DIR='/var/www'
51-
52-
if [ "$( cd ../..; pwd )" != "${ROOT_WWW_DIR}" ]; then
53-
echo "[PHP WRAPPER] Error: The application home directory is expected under ${ROOT_WWW_DIR}/"
54-
exit 1
55-
fi
56-
APP_HOME_DIR="$( cd ..; pwd )"
57-
5851
# Unset MySQL host address and port environment variables if they are not set in the vhost
5952
if [[ ${DB_MYSQL_PORT_3306_TCP_ADDR} == '${DB_MYSQL_PORT_3306_TCP_ADDR}' ]]; then
6053
export DB_MYSQL_PORT_3306_TCP_ADDR=

0 commit comments

Comments
 (0)