Skip to content

Instantly share code, notes, and snippets.

@hariadi
Created April 10, 2017 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hariadi/29ffddf3362f8cd18394b1aeb00dfec0 to your computer and use it in GitHub Desktop.
Save hariadi/29ffddf3362f8cd18394b1aeb00dfec0 to your computer and use it in GitHub Desktop.
Fresh Tuning XAMPP
#!/bin/bash
#
# Fresh tuning for XAMPP
# This scripts highly customize from https://github.com/h5bp/server-configs-apache
#
# Installation
# 1. Download this scripts and put tuning-xampp.sh on your XAMPP root (i.e C:\xampp)
# 2. Open Git Bash, chmod a+x tuning-xampp.sh
# 3. sh tuning-xampp.sh domain path - Example: sh tuning-xampp.sh apps.jpa.gov.my "C:/www"
# 4. Check Apache config by running: apache/bin/httpd -t
#
XAMPP_DIR=$(command)
MODULES=(autoindex deflate expires filter headers include mime rewrite setenvif)
APACHE_CONFIG="apache/conf"
EXTRA_CONFIG="$APACHE_CONFIG/extra"
MAIN_CONFIG="$APACHE_CONFIG/httpd.conf"
SSL_CONFIG="$EXTRA_CONFIG/httpd-ssl.conf"
VHOSTS_CONFIG="$EXTRA_CONFIG/httpd-vhosts.conf"
H5BP_SERVER_CONFIG="apache/conf/extra/h5bp"
LOGS_DIR="apache/logs"
PATH_CRT="conf/ssl.crt"
PATH_KEY="conf/ssl.key"
if [[ "$1" && "$2" ]]
then
# Clone H5BP
if [ ! -d "$H5BP_SERVER_CONFIG" ]
then
git clone https://github.com/h5bp/server-configs-apache.git
cp- r $H5BP_SERVER_CONFIG/src apache/conf/extra/h5bp
fi
# ENABLE H5BP MODULES
if [ ! -f ${MAIN_CONFIG}.backup ]; then
cp $MAIN_CONFIG ${MAIN_CONFIG}.backup
fi
for i in ${MODULES[@]}; do
echo "===== Enable ${i}_module ====="
sed -i "/${i}_module/s/^#//g" "$MAIN_CONFIG"
if [ $? = "1" ]; then
echo "FAILURE : Cannot enable $i "
exit 1
fi
echo "SUCCESS : $i enabled ";
done
# SETUP SSL
if [ ! -f ${SSL_CONFIG}.backup ]; then
cp $SSL_CONFIG ${SSL_CONFIG}.backup
fi
echo "===== Setup SSL CRT & KEY for $1 in $PATH_CRT ====="
sed -i 's#SSLProtocol .*#SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1#' ${SSL_CONFIG}
sed -i '/SSLHonorCipherOrder on/a SSLCompression off' ${SSL_CONFIG}
sed -i '/SSLCompression off/a SSLSessionTickets off' ${SSL_CONFIG}
sed -i 's#SSLProxyProtocol .*#SSLProxyProtocol all -SSLv3#' ${SSL_CONFIG}
sed -i 's#SSLCertificateFile .*#SSLCertificateFile "'"$PATH_CRT/$1.crt"'"#' ${SSL_CONFIG}
sed -i 's#SSLCertificateKeyFile .*#SSLCertificateKeyFile "'"$PATH_KEY/$1.key"'"#' ${SSL_CONFIG}
sed -i 's#\#SSLCertificateChainFile .*#\#SSLCertificateChainFile "'"$PATH_CRT/$1-chain.key"'"#' ${SSL_CONFIG}
sed -i '/#SSLUseStapling .*/a SSLStaplingResponderTimeout 5' ${SSL_CONFIG}
sed -i "/#SSLUseStapling/s/^#//g" ${SSL_CONFIG}
sed -i '/#SSLStaplingCache .*/a SSLStaplingReturnResponderErrors off' ${SSL_CONFIG}
sed -i "/#SSLStaplingCache/s/^#//g" ${SSL_CONFIG}
if [ ! -f "$LOGS_DIR/ssl_stapling" ]; then
touch $LOGS_DIR/ssl_stapling
fi
sed -i 's#SSLStaplingCache .*#SSLStaplingCache "'"shmcb:${LOGS_DIR}/ssl_stapling(128000)"'"#' ${SSL_CONFIG}
# SETUP WEBROOT
sed -i 's#DocumentRoot .*#DocumentRoot "'"$2"'"#' ${SSL_CONFIG}
sed -i 's#ServerName .*#ServerName '$1':443#' ${SSL_CONFIG}
else
echo "Error: missing required parameters."
echo "Usage: "
echo " sh tuning-xampp.sh domain path"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment