Brotli简单介绍

Brotli介绍 Brotli 是基于 LZ77 算法的一个现代变体、霍夫曼编码和二阶上下文建模。Google 软件工程师在 2015 年 9 月发布了包含通用无损数据压缩的 Brotli 增强版本,特别侧重于 HTTP 压缩。其中的编码器被部分改写以提高压缩比,编码器和解码器都提高了速度,流式 API 已被改进,增加更多压缩质量级别。 和谷歌的gzip解压缩格式比起来,Brotli能在此基础上将数据在压缩20~25%。它通过一本英语、西班牙语、汉语、印地语、俄语、阿拉伯语的常用字、词汇字典,结合机器语言,特别是HTML和JavaScript的常用术语,能够将数据比gzip, bzip2, LZMA等压缩算法的基础上进一步进行压缩,减少了数据内容的容量大小,使得网页在加载时速度更快。 Brotli压缩级别 Brotli 有 12 个压缩级别,从 0 到 11,其中 0 提供最快的压缩速度但压缩比最低,而 11 提供最高的压缩比但需要更多的计算资源和时间。 在Cloudflare 使用中提供了CSS文件使用Gzip和Brotli压缩对比 通过压缩到 Brotli 11 级,用户可以将文件大小比最佳 Gzip 压缩级别减少 19%。此外,最强的 Brotli 压缩级别比 Cloudflare 默认使用级别将文件大小减少约 18%。这凸显了利用 Brotli 压缩可显著减少文件大小,特别是在其最高级别下,从而提高网站性能、加快页面加载时间并减少总体出站费用。 Brotli支持情况 可通过网站caniuse.com 查看浏览器对Brotli支持情况
Read More ~

CentOS/AnoliOS编译Nginx

Nginx 介绍 Nginx是一种流行的开源Web服务器和反向代理服务器。 它的官方网站是nginx.org,而nginx.com是Nginx软件的商业版本的网站。 nginx.org是Nginx的官方网站,提供了所有版本的Nginx软件的下载,包括稳定版、主线版和开发版。 我们平时还是会使用开源版本,以下为开源版本编译介绍 安装准备 1 官网下载源码 一般我们会使用Stable version版本的代码 命令:wget https://nginx.org/download/nginx-1.26.0.tar.gz 2 编译库安装 GCC编译器 : gcc gcc-c++ 正则表达式PCRE库 : pcre pcre-devel zlib压缩库 : zlib zlib-devel OpenSSL开发库 : openssl openssl-devel 命令:yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 如果系统为8以上,也可以使用dnf install -y 开始编译 # 创建nginx用户与用户组 groupaddd nginx useradd -g nginx nginx #解压nginx源码包并进入nginx源码根目录 [root@localhost ~]# tar -axv -f nginx-1.26.0.tar.gz && cd nginx-1.26.0 # 1 生成makefile文件 ./configure \ --prefix=/etc/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_temp \ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ --user=nginx \ --group=nginx \ --with-file-aio \ --with-threads \ --with-http_addition_module \ --with-http_auth_request_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_mp4_module \ --with-http_random_index_module \ --with-http_realip_module \ --with-http_secure_link_module \ --with-http_slice_module \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_sub_module \ --with-http_v2_module \ --with-stream \ --with-stream_realip_module \ --with-stream_ssl_module \ --with-stream_ssl_preread_module # 2 编译和安装 make && make install # 3 安装成功执行以下命令查看nginx版本号 [root@localhost nginx]# nginx -v nginx version: nginx/1.26.0 nginx -V 可以看到除了版本之外其他安装模块信息 如果想在Nginx中使用brotli压缩,可如下操作 # 安装brotli dnf install -y brotli brotli-devel 或 yum install -y brotli brotli-devel # 在编译时,添加brotli模块 ./configure \ --prefix=/etc/nginx \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --http-client-body-temp-path=/var/cache/nginx/client_temp \ --http-proxy-temp-path=/var/cache/nginx/proxy_temp \ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ --http-scgi-temp-path=/var/cache/nginx/scgi_temp \ --user=nginx \ --group=nginx \ --with-file-aio \ --with-threads \ --with-http_addition_module \ --with-http_auth_request_module \ --with-http_dav_module \ --with-http_flv_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_mp4_module \ --with-http_random_index_module \ --with-http_realip_module \ --with-http_secure_link_module \ --with-http_slice_module \ --with-http_ssl_module \ --with-http_stub_status_module \ --with-http_sub_module \ --with-http_v2_module \ --with-stream \ --with-stream_realip_module \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ --add-module=/opt/soft/install/ngx_brotli 添加服务并设置开机启动 1、服务配置 [root@localhost]# vim /usr/lib/systemd/system/nginx.service [Unit] Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network.target remote-fs.target nss-lookup.target ​ [Service] Type=forking PIDFile=/etc/nginx/logs/nginx.pid ExecStartPre=/etc/nginx/sbin/nginx -t -c /etc/nginx/conf/nginx.conf ExecStart=/etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf ExecReload= /etc/nginx/sbin/nginx -s reload ExecStop= /etc/nginx/sbin/nginx -s stop PrivateTmp=true ​ [Install] WantedBy=multi-user.target 2、设置执行权限 [root@localhost]# chmod +x /usr/lib/systemd/system/nginx.service 3、服务使用说明 [root@localhost.com sbin]## systemctl daemon-reload # 重新加载服务 [root@localhost.com sbin]# systemctl start nginx.service # 启动 [root@localhost.com sbin]#systemctl stop nginx.service # 停止 [root@localhost.com sbin]# systemctl reload nginx.service # 修改配置后重新加载生效 [root@localhost.com sbin]# systemctl restart nginx.service # 重启 [root@localhost.com sbin]# systemctl status nginx # 查看服务状态 4、设置开机启动 [root@localhost]# systemctl enable nginx.service
Read More ~

Gridea介绍使用

Gridea 介绍 Gridea 是一款简单、轻量级(小而且美)的博客搭建工具,适合那些喜欢写作并且想要建立自己的博客的人。它的设计理念是提供一个简洁但功能强大的平台,让用户专注于创作内容,而不必担心复杂的技术细节。 Gridea 特点 离线写作:你可以在离线状态下编写文章,随时随地记录灵感,不需要依赖互联网连接。 Markdown 写作:采用 Markdown 标记语言,让写作变得简单、高效,同时支持代码高亮、数学公式等。 本地存储:所有数据都存储在本地,不依赖于第三方服务器,保护你的隐私和数据安全。 主题和插件支持:Gridea 提供了多种主题和插件,可以根据自己的喜好和需求进行定制和扩展,使博客更加个性化。 多平台同步:支持将文章同步到各种平台,如 GitHub Pages、Gitee pages、Vercel、Netlify 等,让你的博客随时随地都能被访问到。 轻量级、快速部署:Gridea 的客户端非常轻量,下载安装非常迅速,而且部署到各种托管平台也非常简单。 Gridea 总结 在使用过Ghost,Halo,Wordpress,Hugo等博客系统,最后还是选择了Gridea,他可以当作本地文档,随时查看编辑。也可以随时同步博客,没有hugo的繁琐,但是拥有了hugo维护的简洁。无忧的使用github就好,节省了服务器,如果愿意的话,自己买个域名就可以。省心省力,如官网所说的:写博客的那个劲儿又回来了 Gridea官网:https://gridea.dev/ Gridea开源版本:https://open.gridea.dev/
Read More ~

Hello Gridea

👏 欢迎使用 Gridea
✍️ Gridea 一个静态博客写作客户端。你可以用它来记录你的生活、心情、知识、笔记、创意... ...

Read More ~