Last active
August 29, 2015 13:56
-
-
Save debility-zz/8838906 to your computer and use it in GitHub Desktop.
apache config converter + secure setting + php secure setting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
CONFIG_FILE="/etc/httpd/conf/httpd.conf" | |
DATE=`date '+%Y%m%d'` | |
if [ -f "${CONFIG_FILE}.orig.${DATE}" ]; then | |
echo '(maybe)apache config file is already converted. :-P' | |
exit | |
fi | |
cp $CONFIG_FILE ${CONFIG_FILE}.orig.${DATE} | |
sed -i \ | |
-e 's/Options Indexes FollowSymLinks/Options FollowSymLinks/' \ | |
-e 's/ServerTokens OS/ServerTokens Prod/' \ | |
-e 's/ServerSignature On/ServerSignature Off/' \ | |
-e '/^Alias \/icons/s/^/#/' \ | |
-e '/^Alias \/error/s/^/#/' \ | |
-e '/^ScriptAlias \/cgi-bin/s/^/#/' \ | |
-e '/<Directory "\/var\/www\/icons">/,/<\/Directory>/s/^/#/' \ | |
-e '/<Directory "\/var\/www\/cgi-bin">/,/<\/Directory>/s/^/#/' \ | |
-e '/<Directory "\/var\/www\/error">/,/<\/Directory>/s/^/#/' \ | |
${CONFIG_FILE} | |
echo -e '\nTraceEnable Off' >> ${CONFIG_FILE} | |
if [ -f "/etc/httpd/conf.d/welcome.conf" ]; then | |
mv -f /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.orig | |
fi | |
if [ -f "/etc/httpd/conf.d/manual.conf" ]; then | |
mv -f /etc/httpd/conf.d/manual.conf /etc/httpd/conf.d/manual.conf.orig | |
fi | |
PHP_INI_FILE="/etc/php.ini" | |
if [ -f "${PHP_INI_FILE}" ]; then | |
cp ${PHP_INI_FILE} ${PHP_INI_FILE}.orig.${DATE} | |
sed -i 's/expose_php = On/expose_php = Off/' ${PHP_INI_FILE} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment