Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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
You can’t perform that action at this time.