1- #! /bin/sh
1+ #! /usr/ bin/env bash
22
33source /etc/apache-bootstrap.conf
44
55# Allow PHP settings to be varied by passing a parameter to php-wrapper
6- PHP_VERSION=$1
7- PHP_WRAPPER_MODE=$2
6+ PHP_PACKAGE_NAME=${1}
87
9- # VirtualHost specific options can be used to override the PHP options set in the wrapper
10- PHP_VHOST_OPTIONS=$3
8+ # Mode of opperation: production,development,debug.
9+ # Used to enable appropriate php options for requirements
10+ PHP_WRAPPER_MODE=${2}
11+
12+ # VirtualHost specific options can be used to override the PHP options set in
13+ # this wrapper
14+ PHP_VHOST_OPTIONS=${3}
1115
1216# Set path to php.ini
1317export PHPRC=/etc
1418
15- export PHP_FCGI_MAX_REQUESTS=15000
16-
17- # PHP child process management (PHP_FCGI_CHILDREN) should always be disabled with mod_fcgid
19+ # PHP child process management should always be disabled with mod_fcgid
1820export PHP_FCGI_CHILDREN=0
21+ export PHP_FCGI_MAX_REQUESTS=15000
1922
2023export REDIRECT_STATUS=200
24+ export TMP=" ${APACHE_CONTENT_ROOT} /var/tmp"
25+ export TEMP=${TMP}
26+ export TMPDIR=${TMP}
2127
22- X_NICE=" /bin/nice"
23- NICENESS_PHP_CGI=" 15"
24-
25- PHP54_INSTALLED=" false"
26- PHP54_X_CGI=/opt/rh/php54/root/usr/bin/php-cgi
27-
28- if [[ -f /opt/rh/php54/enable ]]; then
29- PHP54_INSTALLED=" true"
30- source /opt/rh/php54/enable
31- export X_SCLS=" $( scl enable php54 ' echo $X_SCLS' ) "
32- fi
28+ X_NICE=/bin/nice
29+ X_PHP_CGI_NICENESS=15
30+ X_PHP_CGI=/usr/bin/php-cgi
3331
34- PHP55_INSTALLED=" false"
35- PHP55_X_CGI=/opt/rh/php55/root/usr/bin/php-cgi
32+ if [[ ${PHP_PACKAGE_NAME} == rh-php56 ]] \
33+ && [[ -f /opt/rh/rh-php56/enable ]] \
34+ && [[ -f /opt/rh/rh-php56/root/usr/bin/php-cgi ]]; then
35+ source /opt/rh/rh-php56/enable
36+ export X_SCLS=" $( scl enable rh-php56 ' echo $X_SCLS' ) "
3637
37- if [[ -f /opt/rh/php55/enable ]]; then
38- PHP55_INSTALLED=" true"
38+ X_PHP_CGI=/opt/rh/rh-php56/root/usr/bin/php-cgi
39+ elif [[ ${PHP_PACKAGE_NAME} == php55 ]] \
40+ && [[ -f /opt/rh/php55/enable ]] \
41+ && [[ -f /opt/rh/php55/root/usr/bin/php-cgi ]]; then
3942 source /opt/rh/php55/enable
4043 export X_SCLS=" $( scl enable php55 ' echo $X_SCLS' ) "
41- fi
4244
43- if [[ ${PHP_VERSION} == " php55" ]] && [[ " PHP55_INSTALLED" == " true" ]] && [[ -f ${PHP55_X_CGI} ]]; then
44- X_PHP_CGI=" ${PHP55_X_CGI} "
45- elif [[ ${PHP_VERSION} == " php54" ]] && [[ " PHP54_INSTALLED" == " true" ]] && [[ -f ${PHP54_X_CGI} ]]; then
46- X_PHP_CGI=" ${PHP54_X_CGI} "
47- else
48- # Default to the default distribution version
49- X_PHP_CGI=" /usr/bin/php-cgi"
45+ X_PHP_CGI=/opt/rh/php55/root/usr/bin/php-cgi
46+ elif [[ ${PHP_PACKAGE_NAME} == php54 ]] \
47+ && [[ -f /opt/rh/php54/enable ]] \
48+ && [[ -f /opt/rh/php54/root/usr/bin/php-cgi ]]; then
49+ source /opt/rh/php54/enable
50+ export X_SCLS=" $( scl enable php54 ' echo $X_SCLS' ) "
51+
52+ X_PHP_CGI=/opt/rh/php54/root/usr/bin/php-cgi
5053fi
5154
52- # Unset MySQL host address and port environment variables if they are not set in the vhost
55+ # Unset MySQL environment variables if they are not set in the vhost
5356if [[ ${DB_MYSQL_PORT_3306_TCP_ADDR} == ' ${DB_MYSQL_PORT_3306_TCP_ADDR}' ]]; then
54- export DB_MYSQL_PORT_3306_TCP_ADDR=
57+ unset DB_MYSQL_PORT_3306_TCP_ADDR
5558fi
59+
5660if [[ ${DB_MYSQL_PORT_3306_TCP_PORT} == ' ${DB_MYSQL_PORT_3306_TCP_PORT}' ]]; then
57- export DB_MYSQL_PORT_3306_TCP_PORT=
61+ unset DB_MYSQL_PORT_3306_TCP_PORT
5862fi
5963
60- export TMP=" ${APACHE_CONTENT_ROOT} /var/tmp"
61- export TEMP=${TMP}
62- export TMPDIR=${TMP}
63-
64- # PHP Configuration Options that may need to be customised for different app features
65-
66- # # Important: Make sure you do not add spaces in this setting
6764PHP_OPTIONS_DISABLE_FUNCTIONS=" system,exec,passthru,shell_exec,proc_open,show_source,popen,pcntl_fork,pcntl_exec,escapeshellarg,escapeshellcmd,openlog,closelog,uname,php_uname"
6865PHP_OPTIONS_OPEN_BASE_DIR=" ${APACHE_CONTENT_ROOT} "
6966
7067PHP_OPTIONS_MEMORY_LIMIT=" 32M"
7168PHP_OPTIONS_POST_MAX_SIZE=" 32M"
7269PHP_OPTIONS_UPLOAD_MAX_FILESIZE=" 24M"
7370
74- PHP_OPTIONS_DISPLAY_ERRORS=" Off"
75- PHP_OPTIONS_HTML_ERRORS=" Off"
76- # We use the numeric values here - found for environment with php -r "echo E_ALL & ~E_DEPRECATED;"
71+ # Use numeric values here.
72+ # To identify the correct value use: php -r "echo E_ALL & ~E_DEPRECATED;"
7773# Default Value: E_ALL & ~E_NOTICE = 30711
7874# Development Value: E_ALL | E_STRICT = 32767
7975# Production Value: E_ALL & ~E_DEPRECATED = 22527
8076PHP_OPTIONS_ERROR_REPORTING=22527
77+ PHP_OPTIONS_DISPLAY_ERRORS=" Off"
78+ PHP_OPTIONS_HTML_ERRORS=" Off"
8179
8280PHP_OPTIONS_XDEBUG_SHOW_EXCEPTION_TRACE=" Off"
8381PHP_OPTIONS_XDEBUG_TRACE_ENABLE_TRIGGER=" Off"
@@ -90,7 +88,7 @@ PHP_OPTIONS_XDEBUG_REMOTE_MODE="req"
9088PHP_OPTIONS_XDEBUG_REMOTE_CONNECT_BACK=" Off"
9189PHP_OPTIONS_XDEBUG_PROFILER_ENABLE_TRIGGER=" Off"
9290
93- # The PHP options can be set appropriately for development / debug / production use
91+ # Set the PHP options appropriately for requirements
9492case ${PHP_WRAPPER_MODE} in
9593 development|debug)
9694 PHP_OPTIONS_DISPLAY_ERRORS=" On"
@@ -174,4 +172,8 @@ PHP_OPTIONS="
174172"
175173
176174# FastCGI-enabled PHP executable
177- exec ${X_NICE} -n ${NICENESS_PHP_CGI} ${X_PHP_CGI} ${PHP_OPTIONS} ${PHP_VHOST_OPTIONS}
175+ exec ${X_NICE} \
176+ -n ${X_PHP_CGI_NICENESS} \
177+ ${X_PHP_CGI} \
178+ ${PHP_OPTIONS} \
179+ ${PHP_VHOST_OPTIONS}
0 commit comments