Apache Web Security Optimization

Source: Internet
Author: User

refer to manually compiling and installing Apache install these packages yum install GCC gcc-c++ make pcre pcre-devel zlib-devel-y

./configure \
--PREFIX=/USR/LOCAL/HTTPD \
--enable-deflate \//Support for compressible
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

Next make &&make Install
* * Modify its configuration file vi/etc/init.d/httpd insert the following line at the front of the file

#!/bin/sh

chkconfig:2345 85 15
# description:Apache is a World Wide Web server.


Give it permission to execute chmod +x/etc/init.d/httpd

chkconfig--add httpd
Chkconfig--list httpd
Chkconfig--level httpd
on

establish a soft link ln-s/usr/local/httpd/conf/httpd.conf/etc/httpd.conf
vi/usr/local/apache/conf/httpd.conf Modify the following two lines
Listen:ipv4
ServerName: hostname. Domain name

Open Web Services service httpd start
vim/etc/httpd.conf
LoadModule Headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so//Open Remove Front #
LoadModule Filter_module modules/mod_filter.so
Add at the end:
<ifmodule mod_deflate.c>
Addoutputfilterbytype DEFLATE text/html text/plain text/css text/xml text/javascript
Deflatecompressionlevel 9
Setoutputfilter DEFLATE
</IfModule>

Cd/usr/local/httpd/bin
./apachectl-t
Syntax OK//Verify that the configuration file is successful

Validation Module
./apachectl-t-D dump_modules | grep "Deflate"
Deflate_module (shared)

Web cache./configure \
--PREFIX=/USR/LOCAL/HTTPD \
--enable-deflate \
--enable-expires \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

Vim/etc/httpd.conf
LoadModule Expires_module modules/mod_expires.so
Add at the end:
<ifmodule mod_expires.c>
Expiresactive on
ExpiresDefault "Access plus seconds" expires after//50s
</IfModule>

Cd/usr/local/httpd/bin
./apachectl-t
Syntax OK

View modules./apachectl-t-D dump_modules | grep "Expires"
Expires_module (Shared)

* * Security optimized yum install Zlib-devel-y

./configure \
--PREFIX=/USR/LOCAL/HTTPD \
--enable-deflate \
--ENABLE-SO \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
Master configuration File Modification

<directory "/usr/local/httpd/htdocs" >
Options Indexes FollowSymLinks

AllowOverride NoneRequire all granted下插入:RewriteEngine OnRewriteCond %{HTTP_REFERER} !^http://benet.com/.*$ [NC]RewriteCond %{HTTP_REFERER} !^http://benet.com$ [NC]RewriteCond %{HTTP_REFERER} !^http://www.benet.com/.*$ [NC]RewriteCond %{HTTP_REFERER} !^http://www.benet.com/$ [NC]RewriteRule .*\.(gif|jpg|swf)$ http://www.benet.com/error.png

</Directory>

LoadModule rewrite_module modules/mod_rewrite.so//Open

./apachectl-t-D dump_modules | grep "Rewrite"
Rewrite_module (Shared) * *

* * Hide version information Include conf/extra/httpd-default.conf Go #, open

Vim httpd-default.conf

Servertokens Prod//Display name only, no version
Serversignature OFF

**

Apache Web Security Optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.