apachectl -t -D DUMP_MODULES | grep "deflate"
如果没有安装mod_deflate 模块,重新编译安装 Apache 添加 mod_deflate 模块
systemctl stop httpd.service
cd /usr/local/httpd/conf
mv httpd.conf httpd.conf.bak
yum -y install gcc gcc-c++ pcre pcre-devel zlib-devel
cd /opt/httpd-2.4.29/
./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi --enable-deflate
#加入mod_deflate 模块
make && make install
vim /usr/local/httpd/conf/httpd.conf
--52行--修改
Listen 192.198.80.10:80
--105行--取消注释
LoadModule deflate_module modules/mod_deflate.so
#开启mod_deflate 模块
--197行--取消注释,修改
ServerName www.kgc.com:80
--末行添加--
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript text/jpg text/png
#代表对什么样的内容启用gzip压缩
DeflateCompressionLevel 9
#代表压缩级别,范围为1~9
SetOutputFilter DEFLATE
#代表启用deflate 模块对本站点的输出进行gzip压缩
apachectl -t
#验证配置文件的配置是否正确
apachectl -t -D DUMP_MODULES | grep "deflate"
#检查 mod_deflate 模块是否已安装
deflate_module (shared)
#已安装的正确结果
systemctl start httpd.service
cd /usr/local/httpd/htdocs
先将game.jpg文件传到/usr/local/httpd/htdocs目录下
vim index.html
Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!
apachectl -t -D DUMP_MODULES | grep "expires"
如果没有安装mod_expires 模块
重新编译安装 Apache 添加 mod_expires模块
systemctl stop httpd.service
cd /usr/local/httpd/conf
mv httpd.conf httpd.conf.bak1
yum -y install gcc gcc-c++ pcre pcre-devel zlib-devel
cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi \
--enable-deflate \
--enable-expires #加入mod_expires 模块
make -j2 && makeinstall
vim /usr/local/httpd/conf/httpd.conf
--52行--修改
Listen 192.198.80.10:80
--111行--取消注释
LoadModule expires_module modules/mod_expires.so #开启mod_expires 模块
--199行--取消注释,修改
ServerName www.kgc.com:80
--末行添加--
ExpiresActive On
#打开网页缓存功能
ExpiresDefault "access plus 60 seconds"
#设置缓存60秒
apachectl -t
#验证配置文件的配置是否正确
apachectl -t -D DUMP_MODULES | grep "expires"
#检查 mod_deflate 模块是否已安装
expires_module (shared)
#已安装的正确结果
systemctl start httpd.service
vim /usr/local/httpd/conf/httpd.conf
--491行--取消注释
Include conf/extra/httpd-default.conf
vim /usr/local/httpd/conf/extra/httpd-default.conf
--55行--修改
ServerTokens Prod
#将原本的 Full 改为 Prod,只显示名称,没有版本
#ServerTokens 表示 Server 回送给客户端的响应头域是否包含关于服务器 OS 类型和编译过的模块描述信息。
systemctl restart httpd.service
apachectl -t -D DUMP_MODULES | grep "rewrite"
如果没有安装mod_rewrite 模块,重新编译安装 Apache 添加 mod_rewrite模块
systemctl stop httpd.service
cd /usr/local/httpd/conf
mv httpd.conf httpd.conf.bak2
yum -y install gcc gcc-c++ pcre pcre-devel zlib-devel
cd /opt/httpd-2.4.29/
./configure \
--prefix=/usr/local/httpd \
--enable-so \
--enable-rewrite \ #加入mod_rewrite 模块
--enable-charset-lite \
--enable-cgi \
--enable-deflate \
--enable-expires
make && make install
vim /usr/local/httpd/conf/httpd.conf
--157行--取消注释
LoadModule rewrite_module modules/mod_rewrite.so
--224行--
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
RewriteEngine On #打开 rewrite 功能,加入 mode_rewrite 模块内容
RewriteCond %{HTTP_REFERER} !^http://kgc.com/.*$ [NC] #设置匹配规则
RewriteCond %{HTTP_REFERER} !^http://kgc.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.kgc.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.kgc.com/$ [NC]
RewriteRule .*\.(gif|jpg|swf)$ http://www.kgc.com/error.png #设置跳转动作
cd /usr/local/httpd/htdocs
将w.jpg、error.png文件传到/usr/local/httpd/htdocs目录下
vim index.html
this is kgc.com!
cd /usr/local/httpd/htdocs
vim index.html
this is benet.com!
访问盗链网站