Skip to content

Instantly share code, notes, and snippets.

@debility-zz
Last active August 29, 2015 13:56
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 debility-zz/8838906 to your computer and use it in GitHub Desktop.
Save debility-zz/8838906 to your computer and use it in GitHub Desktop.
apache config converter + secure setting + php secure setting
#!/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