登峰小蚁 2019-10-26
1.网页压缩
2.网页缓存
1.配置防盗链
2.隐藏版本信息
配置网页压缩功能
工作模式的选择与参数优化
配置防盗链
配置隐藏版本号
1.降低了网络传输的字节数,加快网页加载的速度
2.节省流量,改善用户的浏览体验
3.gzip与搜索弓|擎的抓取工具有着更好的关系
1.mod_gzip模块
2.mod_deflate 模块
1.没有内建网页压缩技术,但可使用第三方mod_
1.在开发的时候,内建了mod_deflate 这个模块,取代mod_gzip
1.两者均使用gzip压缩算法,运作原理类似
2.mod_deflate 压缩速度略快,而mod_gzip 的压缩比略高
3.mod_gzip 对服务器CPU的占用要高一些
4.高流量的服务器,使用mod_deflate 可能会比mod_gzip 加载速度更快
1.执行apachectl -t -D DUMP MODULES命令
2.如果输出中没有deflate module (static),说明编译时没有安装
mod_ deflate模块
1../configure --enable-deflate...
2.make && make install
1.AddOutputFilterByType DEFL ATE text/html text/plain text/css
text/xml textjavascript
2.DeflateCompressionL evel
3.SetOutputFilter DEFL .ATE
[ ~]# mkdir /aaa [ ~]# mount.cifs //192.168.10.12/rpm /aaa Password for //192.168.10.12/rpm: [ ~]# cd /aaa [ aaa]# ls LAMP [ aaa]# cd LAMP/ [ LAMP]# ls apr-1.6.2.tar.gz error.png apr-util-1.6.0.tar.gz ha.jpg awstats-7.6.tar.gz httpd-2.4.29.tar.bz2 cronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26.tar.gz Discuz_X2.5_SC_UTF8.zip php-5.6.11.tar.bz2 [ LAMP]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt [ LAMP]# tar zxvf apr-1.6.2.tar.gz -C /opt/ [ LAMP]# tar zxvf apr-util-1.6.0.tar.gz -C /opt [ LAMP]# cd /opt/ [ opt]# ls apr-1.6.2 apr-util-1.6.0 httpd-2.4.29 rh [ opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr [ opt]# mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util [ opt]# yum install gcc gcc-c++ pcre pcre-devel zlib-devel expat-devel -y [ opt]# cd httpd-2.4.29/ [ httpd-2.4.29]# ls ABOUT_APACHE CMakeLists.txt INSTALL NWGNUmakefile acinclude.m4 config.layout InstallBin.dsp os Apache-apr2.dsw configure LAYOUT README Apache.dsw configure.in libhttpd.dep README.cmake apache_probes.d docs libhttpd.dsp README.platforms ap.d emacs-style libhttpd.mak ROADMAP build httpd.dep LICENSE server BuildAll.dsp httpd.dsp Makefile.in srclib BuildBin.dsp httpd.mak Makefile.win support buildconf httpd.spec modules test CHANGES include NOTICE VERSIONING [ httpd-2.4.29]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi [ httpd-2.4.29]# make [ httpd-2.4.29]# make install [ httpd-2.4.29]# cd /usr/local/httpd/ [ httpd]# ls bin cgi-bin error icons lib man modules build conf htdocs include logs manual [ httpd]# cd conf [ conf]# ls extra httpd.conf magic mime.types original [ conf]# vim httpd.conf [ conf]# ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf [ conf]# vim /etc/httpd.conf /deflate,搜索这个关键词 LoadModule deflate_module modules/mod_deflate.so //此行去除注释 /headers,搜索这个关键词 LoadModule headers_module modules/mod_headers.so //此行需要去除注释 /filter,搜索这个关键词 LoadModule filter_module modules/mod_filter.so //此行需要去除注释 /Listen,搜索这个关键词 Listen 192.168.18.128:80 #Listen 80 /ServerName,搜索这个关键词 ServerName www.kgc.com:80 按大写字母G到末行,按o转下行插入 <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript text/ipg text/png DeflateCompressionLevel 9 SetOutputFilter DEFLATE </IfModule> //修改结束后按Esc退出,输入:wq保存退出 [ conf]# /usr/local/httpd/bin/apachectl -t Syntax OK //验证语法是否正确 [ conf]# /usr/local/httpd/bin/apachectl start [ conf]# netstat -ntap | grep 80 tcp 0 0 192.168.18.128:80 0.0.0.0:* LISTEN 82881/httpd [ conf]# ls extra httpd.conf magic mime.types original [ conf]# cd .. [ httpd]# ls bin cgi-bin error icons lib man modules build conf htdocs include logs manual [ httpd]# cd htdocs/ [ htdocs]# ls index.html [ htdocs]# cat index.html <html><body><h1>It works!</h1></body></html> [ htdocs]# cd /usr/local/httpd/bin/ [ bin]# ./apachectl -t -D DUMP_MODULES | grep "deflate" deflate_module (shared)
[ bin]# cd /aaa/LAMP [ LAMP]# ls apr-1.6.2.tar.gz ha.jpg apr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2 awstats-7.6.tar.gz lf.jpg cronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26.tar.gz Discuz_X2.5_SC_UTF8.zip php-5.6.11.tar.bz2 error.png [ LAMP]# cp lf.jpg /usr/local/httpd/htdocs/ //把图片复制到对应的文件夹 [ LAMP]# cd /usr/local/httpd/ [ httpd]# cd htdocs/ [ htdocs]# ls index.html lf.jpg [ htdocs]# vim index.html <html><body><h1>It works!</h1> <img src="lf.jpg"/> </body></html> //格式做以上更改,在当中插入图片,按Esc退出,输入:wq保存退出
输入对方的IP地址之后可以看到添加的图片,我们通过抓包软件可以看到有图片的抓取信息中有在端口处进行gzip压缩处理信息
具体过程如下图所示: