From d79caac6135a3f99b6f3c5195e5dc2f9049ba916 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 15 Mar 2016 01:02:38 +0100 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- .etckeeper | 1 + apache2/modules.d/70_mod_php.conf | 24 +++++++++++++ apache2/modules.d/70_mod_php5.conf | 10 ++++++ init.d/php-fpm | 54 ++++++++++++++++++++---------- 4 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 apache2/modules.d/70_mod_php.conf diff --git a/.etckeeper b/.etckeeper index 0579787..025fccf 100755 --- a/.etckeeper +++ b/.etckeeper @@ -163,6 +163,7 @@ maybe chmod 0644 'apache2/modules.d/40_mod_ssl.conf' maybe chmod 0644 'apache2/modules.d/45_mod_dav.conf' maybe chmod 0644 'apache2/modules.d/46_mod_ldap.conf' maybe chmod 0644 'apache2/modules.d/47_mod_dav_svn.conf' +maybe chmod 0644 'apache2/modules.d/70_mod_php.conf' maybe chmod 0644 'apache2/modules.d/70_mod_php5.conf' maybe chmod 0644 'apache2/modules.d/99_icinga.conf' maybe chmod 0755 'apache2/sarah' diff --git a/apache2/modules.d/70_mod_php.conf b/apache2/modules.d/70_mod_php.conf new file mode 100644 index 0000000..3f36ba4 --- /dev/null +++ b/apache2/modules.d/70_mod_php.conf @@ -0,0 +1,24 @@ + + # The mod_php.so symlink is controlled by + # eselect-php. However, the module name changed from + # php5_module to php7_module so we can't blindly load whatever + # is there. Instead we let eselect-php manage a small + # configuration file that loads the appropriate module. + Include "/var/lib/eselect-php/mod_php.conf" + + # Tell apache that mod_php should handle PHP files. + # + # NOTE: Avoiding AddHandler/AddType for security (bug + # #538822). Please read the related news item! + + SetHandler application/x-httpd-php + + + # PHP source files which are meant to be displayed as + # syntax-highlighted source code. + + SetHandler application/x-httpd-php-source + + + DirectoryIndex index.php index.phtml + diff --git a/apache2/modules.d/70_mod_php5.conf b/apache2/modules.d/70_mod_php5.conf index 05deeb6..bd79f78 100644 --- a/apache2/modules.d/70_mod_php5.conf +++ b/apache2/modules.d/70_mod_php5.conf @@ -1,3 +1,13 @@ +########### +# WARNING # +########### +# +# This file is provided for backwards compatibility only. The Apache +# PHP configuration is now located in 70_mod_php.conf and requires you +# to set -DPHP in your Apache conf.d file. Please examine +# 70_mod_php.conf and update your Apache configuration to use -DPHP +# instead of -DPHP5. Afterwards you may delete this file. +# # Load the module first diff --git a/init.d/php-fpm b/init.d/php-fpm index 6cc26ac..6502ab9 100755 --- a/init.d/php-fpm +++ b/init.d/php-fpm @@ -1,36 +1,38 @@ -#!/sbin/runscript +#!/sbin/openrc-run + +extra_started_commands="reload" +extra_commands="configtest" set_phpvars() { - PHPSLOT=${SVCNAME#php-fpm-} + PHPSLOT="${SVCNAME#php-fpm-}" PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid" - if [ ${PHPSLOT} = 'php-fpm' ] ; then + if [ "${PHPSLOT}" = "php-fpm" ] ; then PHPSLOT="$(eselect php show fpm)" PHP_FPM_PID="/run/php-fpm.pid" fi PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf" -} - -extra_commands="depend" -extra_started_commands="reload" - -depend() { - need net - use apache2 lighttpd nginx + PHP_FPM_BIN="/usr/lib/${PHPSLOT}/bin/php-fpm" } start() { + # If configtest fails, we don't have to sit around for five + # seconds waiting for a pid to show up. + configtest || return $? ebegin "Starting PHP FastCGI Process Manager" set_phpvars - start-stop-daemon --start --pidfile ${PHP_FPM_PID} --exec \ - /usr/lib/${PHPSLOT}/bin/php-fpm -- -y "${PHP_FPM_CONF}" -g "${PHP_FPM_PID}" + start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \ + --exec "${PHP_FPM_BIN}" \ + -- \ + --fpm-config "${PHP_FPM_CONF}" \ + --pid "${PHP_FPM_PID}" local i=0 local timeout=5 - while [ ! -f ${PHP_FPM_PID} ] && [ $i -le $timeout ]; do + while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do sleep 1 i=$(($i + 1)) done - + [ $timeout -gt $i ] eend $? } @@ -38,13 +40,31 @@ start() { stop() { ebegin "Stopping PHP FastCGI Process Manager" set_phpvars - start-stop-daemon --signal QUIT --stop --exec /usr/lib/${PHPSLOT}/bin/php-fpm --pidfile ${PHP_FPM_PID} + start-stop-daemon --signal QUIT \ + --stop \ + --exec "${PHP_FPM_BIN}" \ + --pidfile "${PHP_FPM_PID}" eend $? } reload() { + configtest || return $? ebegin "Reloading PHP FastCGI Process Manager" set_phpvars - [ -f ${PHP_FPM_PID} ] && kill -USR2 $(cat ${PHP_FPM_PID}) + [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}") eend $? } + +configtest() { + ebegin "Testing PHP FastCGI Process Manager configuration" + set_phpvars + # Hide the "test is successful" message (which goes to stderr) if + # the test passed, but show the entire output if the test failed + # because it may contain hints about the problem. + OUTPUT=$( "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test 2>&1 ) + + # Save this so `echo` doesn't clobber it. + local exit_code=$? + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2 + eend $exit_code +} -- 2.39.5