当前位置:首页 > 服务器 > 正文

服务器如何开启gzip(服务器如何开启远程桌面背景)

今天给各位分享服务器如何开启gzip的知识,其中也会对服务器如何开启远程桌面背景进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

教你开启apache服务器gzip压缩配置的操作方法

实现操作

1、找到并打开apache/conf目录中的httpd.conf文件

2、httpd.conf中打开deflate_Module和headers_Module模块,具体做法为将

如下两句前面的#去掉:

LoadModule

deflate_module

modules/mod_deflate.so

LoadModule

headers_module

modules/mod_headers.so

3、在httpd.conf文件底部加入如下代码配置需要压缩的文件类型:

IfModule

deflate_moduleSetOutputFilter

DEFLATE#

Don’t

compress

images

and

otherSetEnvIfNoCase

Request_URI

.(?:gif|jpe?g|png)$

no-gzip

dont-varySetEnvIfNoCase

Request_URI

.(?:exe|t?gz|zip|bz2|sit|rar)$

no-gzip

dont-varySetEnvIfNoCase

Request_URI

.(?:pdf|doc)$

no-gzip

dont-varyAddOutputFilterByType

DEFLATE

text/html

text/plain

text/xml

text/cssAddOutputFilterByType

DEFLATE

application/x-javascript/IfModule

4、重启apache服务端

5、使用站长工具查看是否已经开启。

Nginx开启和配置Gzip压缩

nginx 是一个高性能的 Web 服务器,合理配置nginx可以有效提高网站的响应速度。

本文介绍 nginx 的 gzip 和缓存开启配置。

gzip的压缩页面需要浏览器和服务器双方都支持,实际上就是服务器端压缩,传到浏览器后浏览器解压并解析。

Nginx的压缩输出有一组gzip压缩指令来实现。

相关指令位于 http{…} 两个大括号之间。

pre style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1rem; overflow: auto; display: block; color: rgb(33, 37, 41); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"# 开启gzip

gzip on;

gzip_min_length 1k;

gzip_comp_level 6;

gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

gzip_vary on;

gzip_disable "MSIE [1-6].";/pre

关于具体的参数说明可以参考 nginx 的文档 。

pre style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 14px; margin-top: 0px; margin-bottom: 1rem; overflow: auto; display: block; color: rgb(33, 37, 41); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"location ~* ^.+.(ico|gif|jpg|jpeg|png)$ {

access_log off;

expires 30d;

}

location ~* ^.+.(css|js|txt|xml|swf|wav)$ {

access_log off;

expires 24h;

}

location ~* ^.+.(html|htm)$ {

expires 1h;

}/pre

其中的缓存时间可以自己根据需要修改。

服务器开启Gzip压缩功能

在负载均衡中有一个必须要做的事情就是给服务器开启Gzip压缩功能,对用户请求的页面进行压缩处理,以达到节省网络带宽,提高网站速度的作用。

Gzip是若干文件压缩程序的简称,通常指GNU计划的实现,此处的Gzip代表的就是GUN ZIP,这也是HTTP1.1协议定义的两种压缩方法中最常用的一种压缩方法,客户端浏览器大都支持这种压缩格式。

接下来,将介绍Apache、Nginx 如何开启Gzip压缩。

Apache开启Gzip要看查看是否已经开启mod_deflate模块,如果没有则需要先加载,在配置文件httpd.conf中将

前面的#号去掉。另外,如果对Apache的配置文件不太懂的客户在修改配置文件之前对配置文件进行备份。

开启模块后,在httpd.conf配置文件的最下面空白处添加一下内容:

其中DeflateCompressionLevel 的意思是压缩等级,共分为1-9,9级为最高,不建议使用太高的压缩比,这样会对CPU产生太大的负担。

打开配置文件 nginx.conf找到Gzip on 把前面的注释符号#去掉即可开启GZIP服务。然后配置GZIP即可。

下面是一个相对优化不错的配置。

服务器如何开启gzip的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于服务器如何开启远程桌面背景、服务器如何开启gzip的信息别忘了在本站进行查找喔。

取消
扫码支持 支付码