From b09d597c845cd77b8ed1c21832805fb44e68b84c Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 5 Apr 2016 21:40:48 +0800 Subject: [PATCH] fix compatible: apache before 2.4 and after 2.4 --- le.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/le.sh b/le.sh index a85c1329..cd814c84 100755 --- a/le.sh +++ b/le.sh @@ -783,13 +783,31 @@ _setApache() { _info "The backup file will be deleted on sucess, just forget it." #add alias - echo " + + apacheVer="$(apachectl -V | grep "Server version:" | cut -d : -f 2 | cut -d " " -f 2 | cut -d '/' -f 2 )" + _debug "apacheVer" "$apacheVer" + apacheMajer="$(echo "$apacheVer" | cut -d . -f 1)" + apacheMinor="$(echo "$apacheVer" | cut -d . -f 2)" + + if [[ "$apacheVer" ]] && [[ "$apacheMajer" -ge "2" ]] && [[ "$apacheMinor" -ge "4" ]] ; then + echo " Alias /.well-known/acme-challenge $ACME_DIR Require all granted + + " >> $httpdconf + else + echo " +Alias /.well-known/acme-challenge $ACME_DIR + + +Order allow,deny +Allow from all " >> $httpdconf + fi + if ! apachectl -t ; then _err "Sorry, apache config error, please contact me."