From 95b71b49fb96bad7eaae48dfd64a2b9066f3b982 Mon Sep 17 00:00:00 2001 From: Teddysun Date: Sun, 10 Dec 2017 11:38:00 +0900 Subject: [PATCH] Add Apache additional modules Change mpm from prefork to event (Apache 2.4 only) Signed-off-by: Teddysun --- include/apache.sh | 44 ++++++++++++++++++++++++++++++++++++++- include/upgrade_apache.sh | 8 ++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/include/apache.sh b/include/apache.sh index c8da91e..ad8f556 100644 --- a/include/apache.sh +++ b/include/apache.sh @@ -15,6 +15,7 @@ apache_preinstall_settings(){ display_menu apache 2 + display_menu_multi apache_modules last if [[ "$apache" != "do_not_install" ]];then if [ "$apache" == "${apache2_2_filename}" ];then @@ -35,7 +36,7 @@ apache_preinstall_settings(){ elif [ "$apache" == "${apache2_4_filename}" ];then apache_configure_args="--prefix=${apache_location} \ --with-pcre=${depends_prefix}/pcre \ - --with-mpm=prefork \ + --with-mpm=event \ --with-included-apr \ --with-ssl \ --with-nghttp2 \ @@ -230,3 +231,44 @@ EOF boot_start httpd } + +install_apache_modules(){ + if_in_array "${mod_wsgi_filename}" "${apache_modules_install}" && install_mod_wsgi + if_in_array "${mod_jk_filename}" "${apache_modules_install}" && install_mod_jk +} + +install_mod_wsgi(){ + cd ${cur_dir}/software/ + log "Info" "${mod_wsgi_filename} install start..." + download_file "${mod_wsgi_filename}.tar.gz" + tar zxf ${mod_wsgi_filename}.tar.gz + cd ${mod_wsgi_filename} + + error_detect "./configure --with-apxs=${apache_location}/bin/apxs" + error_detect "make" + error_detect "make install" + # add mod_wsgi to httpd.conf + if [[ `grep -E -c "^\s*LoadModule wsgi_module modules/mod_wsgi.so" ${apache_location}/conf/httpd.conf` -eq 0 ]]; then + lnum=$(sed -n '/LoadModule/=' ${apache_location}/conf/httpd.conf | tail -1) + sed -i "${lnum}aLoadModule wsgi_module modules/mod_wsgi.so" ${apache_location}/conf/httpd.conf + fi + log "Info" "${mod_wsgi_filename} install completed..." +} + +install_mod_jk(){ + cd ${cur_dir}/software/ + log "Info" "${mod_jk_filename} install start..." + download_file "${mod_jk_filename}.tar.gz" + tar zxf ${mod_jk_filename}.tar.gz + cd ${mod_jk_filename}/native + + error_detect "./configure --with-apxs=${apache_location}/bin/apxs --enable-api-compatibility" + error_detect "make" + error_detect "make install" + # add mod_jk to httpd.conf + if [[ `grep -E -c "^\s*LoadModule jk_module modules/mod_jk.so" ${apache_location}/conf/httpd.conf` -eq 0 ]]; then + lnum=$(sed -n '/LoadModule/=' ${apache_location}/conf/httpd.conf | tail -1) + sed -i "${lnum}aLoadModule jk_module modules/mod_jk.so" ${apache_location}/conf/httpd.conf + fi + log "Info" "${mod_jk_filename} install completed..." +} diff --git a/include/upgrade_apache.sh b/include/upgrade_apache.sh index af5339a..2f69e05 100644 --- a/include/upgrade_apache.sh +++ b/include/upgrade_apache.sh @@ -101,7 +101,7 @@ upgrade_apache(){ elif [ "${apache_version}" == "2.4" ];then apache_configure_args="--prefix=${apache_location} \ --with-pcre=${depends_prefix}/pcre \ - --with-mpm=prefork \ + --with-mpm=event \ --with-included-apr \ --with-ssl \ --with-nghttp2 \ @@ -141,6 +141,12 @@ upgrade_apache(){ cp -rpf ${apache_location}.bak/conf/* ${apache_location}/conf/ cp -rpf ${apache_location}.bak/modules/libphp* ${apache_location}/modules/ cp -pf ${apache_location}.bak/bin/envvars ${apache_location}/bin/envvars + if [ -f ${apache_location}.bak/modules/mod_wsgi.so ]; then + cp -pf ${apache_location}.bak/modules/mod_wsgi.so ${apache_location}/modules/ + fi + if [ -f ${apache_location}.bak/modules/mod_jk.so ]; then + cp -pf ${apache_location}.bak/modules/mod_jk.so ${apache_location}/modules/ + fi log "Info" "Clear up start..." cd ${cur_dir}/software