Apache 网页优化
在 Linux 中搭建的 Apache ,要进行优化必须是在编译安装环境下进行,并编译安装。要注意,在./配置的时候,要添加以下模块。
./configure \
--prefix=/usr/local/httpd \ ##安装目录
--enable-deflate \ ##压缩模块
--enable-expires \ ##缓存模块
--enable-so \
--enable-rewrite \ ##重写功能
--enable-charset-lite \
--enable-cgi
一、配置压缩模块
打开主配置文件,打开压缩模块
vim /usr/local/httpd/conf/httpd.conf
LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so ##开启 去掉前面#
LoadModule filter_module modules/mod_filter.so
##在末尾添加下面的行
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript ##支持压缩的格式
DeflateCompressionLevel 6 ##压缩比<