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