File tree Expand file tree Collapse file tree 5 files changed +60
-1
lines changed
Images/Linux/宝塔nginx安装ngx_brotli Expand file tree Collapse file tree 5 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 28
28
:::
29
29
30
30
## aaPanel
31
- 其实宝塔面板还有一个孪生兄弟,叫 ` aaPanel ` , 针对国外用户,这个版本更干净,少了许多广告和限制 ,习惯了中文宝塔的安装 ` aaPanel ` 也很容易上手
31
+ 其实宝塔面板还有一个孪生兄弟,叫 ` aaPanel ` , 针对国外用户,这个版本更干净,强制绑定宝塔账号的限制 ,习惯了中文宝塔的安装 ` aaPanel ` 也很容易上手
32
32
33
33
``` shell
34
34
URL=https://www.aapanel.com/script/install_7.0_en.sh && if [ -f /usr/bin/curl ]; then curl -ksSO " $URL " ; else wget --no-check-certificate -O install_7.0_en.sh " $URL " ; fi ; bash install_7.0_en.sh aapanel
Original file line number Diff line number Diff line change
1
+ # 宝塔nginx安装ngx_brotli
2
+
3
+ ## 介绍
4
+ ` br ` 是 ` Brotli ` 的缩写,是 ` Google ` 出的一种文件压缩工具,根据 ` Google ` 的官方数据和实际使用经验,` Brotli ` 相对于 ` Gzip ` 可以实现更高的压缩率,有时候可以达到 ` 20-30% ` 的压缩率提升。感兴趣可以参考这篇[ Gzip vs Brotli 压缩算法,谁更好?及最优实施方案] ( https://zhanzhangb.cn/tutorials/gzip-vs-brotli-better-compression.html )
5
+
6
+
7
+ ` nginx ` 默认安装不带` brotli ` 支持,所以我们需要手动编译安装 ` nginx ` 启用 ` brotli ` 支持。
8
+
9
+ ::: warning 注意
10
+ 无特殊需求,建议选极速安装,非必要不要选 ` 编译安装 ` , 相当的慢,我测试 ` brotli ` ,在 ` ubuntu 18.04 ` 和 ` 20.04 ` 上重新编译 ` nginx ` , 等了很长时间不提,最后还编译失败了。
11
+ ![ 18.04_error] ( /Images/Linux/宝塔nginx安装ngx_brotli/18.04_error.png " 18.04_error ")
12
+
13
+ 最后,在 ` 22.04 ` 花了将近一个小时,终于编译成功。
14
+ :::
15
+
16
+ ## 卸载已安装的nginx
17
+ 如果面板还没有安装 ` nginx ` ,可以跳过此步骤。
18
+
19
+ 登录宝塔面板 => 软件商品 => 已安装 => 找到 ` nginx ` => 卸载
20
+
21
+ ## 安装ngx_brotli
22
+ 1 . 以 ` root ` 用户登录到 ` vps ` 终端
23
+
24
+ ``` shell
25
+ # 进入对应目录
26
+ cd /www/server
27
+ # 下载ngx_brotli
28
+ git clone --recurse-submodules -j8 https://github.com/google/ngx_brotli
29
+ # 添加ngx_brotli编译参数
30
+ echo " --add-module=/www/server/ngx_brotli" > /www/server/panel/install/nginx_configure.pl
31
+ ```
32
+ 1. 宝塔面板 => 软件商品 => 搜索 ` nginx` => 安装 => 勾选 ` 编译安装` => 提交
33
+
34
+ # # 使用
35
+ 在宝塔面板新建一个网站,打开 ` nginx` 配置文件,添加如下配置并保存。
36
+
37
+ ` ` ` nginx
38
+ brotli on;
39
+ brotli_comp_level 1;
40
+ brotli_buffers 16 8k;
41
+ brotli_min_length 20;
42
+ brotli_types text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml text/javascript image/tiff image/svg+xml application/json application/xml;
43
+ ` ` `
44
+
45
+ 再次访问网页,可以看到 ` Content-Encoding: br` ,说明成功了。
46
+ ! [internet_br](/Images/Linux/宝塔nginx安装ngx_brotli/internet_br.jpg " internet_br" )
47
+
48
+
49
+
50
+
51
+
52
+
53
+ # # 参考
54
+ 1. [宝塔面板](https://www.bt.cn/new/download.html)
55
+ 1. [aaPanel](https://www.aapanel.com/new/download.html#install)
56
+ 1. [宝塔面板Nginx开启Brotli压缩,提升网站加载速度-【给网站提提速】](https://developer.aliyun.com/article/1253206)
57
+ 1. [Nginx 启用 QUIC 与 Brotli 的完整教程(宝塔面板8.0.6)](https://zhanzhangb.cn/tutorials/nginx-quic-brotli-bt.html)
58
+ 1. [Gzip vs Brotli 压缩算法,谁更好?及最优实施方案](https://zhanzhangb.cn/tutorials/gzip-vs-brotli-better-compression.html)
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ const rowWrapVal = ref(true)
213
213
<a-button href =" /Docs/Linux/Shell/Ubuntu安装wireshark " >Ubuntu安装wireshark</a-button >
214
214
<a-button href =" /Docs/Linux/Shell/Ubuntu安装flatpak软件 " >Ubuntu安装flatpak软件</a-button >
215
215
<a-button href =" /Docs/Linux/Shell/安装Bt面板 " >安装Bt面板</a-button >
216
+ <a-button href =" /Docs/Linux/Shell/宝塔nginx安装ngx_brotli " >宝塔nginx安装ngx_brotli</a-button >
216
217
</a-row >
217
218
218
219
<!-- Windows -->
You can’t perform that action at this time.
0 commit comments