summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2015-12-10 19:24:32 -0500
committerMichael Orlitzky <mjo@gentoo.org>2015-12-10 19:24:32 -0500
commitc5c96ff3aa9777818de6185045c41426214e3493 (patch)
treef90c0b3db01c5c26da98910f889033c674a30375
parentUse {cli,cgi,fpm}_link variables where appropriate. (diff)
downloadeselect-php-c5c96ff3aa9777818de6185045c41426214e3493.tar.gz
eselect-php-c5c96ff3aa9777818de6185045c41426214e3493.tar.bz2
eselect-php-c5c96ff3aa9777818de6185045c41426214e3493.zip
Write an apache configuration file to /var/lib/eselect-php/mod_php.conf.
With the mod_php.so symlinking done, we realize a new problem: each apache module has its "module name" hardcoded into the binary. For example, in mod_php7.c, we find, AP_MODULE_DECLARE_DATA module php7_module and likewise with php5_module in the 5.x series of PHP. This means that we can't load both of these modules with one LoadModule statement regardless of its filename -- we need to know the module name too. This commit adds a function to write out an apache config file for the current active module. The main apache config file should Include this file, which will be updated whenever an apache2 target is set.
-rw-r--r--src/php.eselect.in39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/php.eselect.in b/src/php.eselect.in
index ea8676f..aa8ad68 100644
--- a/src/php.eselect.in
+++ b/src/php.eselect.in
@@ -208,6 +208,37 @@ get_active_apache2() {
fi
}
+# Write an apache configuration file to load the active version of
+# mod_php. The 5.x and 7.x series (at least...) have different module
+# names, and so require a different apache configuration when
+# switching between the two.
+#
+# INPUT:
+#
+# The name of the target (php5.6, php7.0) for which to write the
+# configuration file.
+#
+# OUTPUT:
+#
+# None.
+#
+write_mod_php_conf() {
+ local target="${1}"
+ local conf_dir="${EROOT}"/var/lib/eselect-php
+ local conf_path="${conf_dir}/mod_php.conf"
+
+ mkdir -p "${conf_dir}" || die "failed to create ${conf_dir}"
+
+ # Parse the major version (for example "5" or "7") out of the
+ # target name.
+ local major="${target:3:1}"
+ cat <<-EOF > "${conf_path}" || die "failed to write mod_php.conf"
+ <IfModule !php${major}_module>
+ LoadModule php${major}_module modules/mod_php.so
+ </IfModule>
+ EOF
+}
+
resolv_target() {
local targets=( $(find_targets_$1) )
if is_number $2; then
@@ -279,18 +310,20 @@ list_fpm() {
}
set_apache2() {
- local active_symlink libdir t=$(resolv_target apache2 $1)
+ local active_symlink libdir target=$(resolv_target apache2 $1)
active_symlink="$(get_apache2_active_symlink_path)"
- [[ -z $t ]] && die -q "invalid target"
+ [[ -z $target ]] && die -q "invalid target"
for libdir in $(get_libdirs); do
rm --force "${active_symlink}" || \
die "failed to remove active module symlink"
- @LN_S@ --force "../../${t}/apache2/libphp${t:3:1}.so" \
+ @LN_S@ --force "../../${target}/apache2/libphp${target:3:1}.so" \
"${active_symlink}" || \
die -q "failed to create active mod_php symlink"
done
+
+ write_mod_php_conf "${target}"
echo "Please restart apache for the changes to take effect."
}