From 7189eaa6915d59d031f3c91f2b5e51b1a455aa20 Mon Sep 17 00:00:00 2001
From: mobeicanyue <81098819+mobeicanyue@users.noreply.github.com>
Date: Fri, 3 May 2024 02:36:23 +0800
Subject: [PATCH] update articles
---
.../Caddy-installation-and-usage-tutorial.md | 3 +-
source/_posts/Compress-deploy-code-size.md | 90 -------------------
.../Deploy-a-springboot-project-to-server.md | 2 +-
.../Deploying-a-Web-Disk-of-Your-Own.md | 26 +++++-
...ail2ban-installation-and-usage-tutorial.md | 4 +-
source/_posts/How-to-Deploy-a-new-server.md | 29 ++++--
.../Nginx-installation-and-usage-tutorial.md | 3 +-
source/_posts/Tutorial-of-Building-a-blog.md | 1 -
.../Umami-installation-and-usage-tutorial.md | 2 +-
9 files changed, 54 insertions(+), 106 deletions(-)
delete mode 100644 source/_posts/Compress-deploy-code-size.md
diff --git a/source/_posts/Caddy-installation-and-usage-tutorial.md b/source/_posts/Caddy-installation-and-usage-tutorial.md
index cc37019b..e189975c 100644
--- a/source/_posts/Caddy-installation-and-usage-tutorial.md
+++ b/source/_posts/Caddy-installation-and-usage-tutorial.md
@@ -23,9 +23,8 @@ Nginx 是一个被广泛使用的 Web 服务器,但是它的配置相对 Caddy
输入以下命令安装 Caddy:
```bash
sudo apt update
-sudo apt install caddy
+sudo apt install caddy -y
```
-系统会提示是否安装,`回车` 或输入 `Y` 确认安装。
安装完成后,可以使用以下命令检查 Caddy 的版本:
```bash
diff --git a/source/_posts/Compress-deploy-code-size.md b/source/_posts/Compress-deploy-code-size.md
deleted file mode 100644
index a7c25ba7..00000000
--- a/source/_posts/Compress-deploy-code-size.md
+++ /dev/null
@@ -1,90 +0,0 @@
----
-title: 压缩前端代码
-tags:
- - Hexo
- - 优化
-abbrlink: a89b8953
-date: 2023-12-28 02:51:41
----
-众所周知,我们在写 HTML CSS 和 JS 文件时文件中会包含许多换行和空格。
-然而,这些换行和空格对浏览器而言并不具备实际意义,反而可能降低页面的加载速度,会对页面的渲染性能造成一定影响。比如我们看个
-[`jquery` 的源码](https://lib.baomitu.com/jquery/3.6.4/jquery.min.js)
-可以发现代码密密麻麻没有一点可读性,但是`这样的代码浏览器来说加载起来更快`,因为`浏览器不需要去解析空格和换行符,而是直接读取代码`。
-
-因此,为了优化页面性能,我们需要对页面的静态资源进行压缩,包括 CSS、JS 和 HTML、图片、字体等。为了简化这一过程,可使用 Hexo 插件 `hexo-minify` 进行压缩操作。这样一来,我们可以有效地减少文件大小,提升页面加载速度。
-
-### 1. 安装 hexo-minify 插件
-
-在你的 Hexo 博客目录下,执行以下命令安装 hexo-minify 插件:
-```bash
-npm install hexo-minify --save
-```
-
-### 2. 配置 hexo-minify 插件
-具体用法及参数请查阅[官方文档](https://github.com/Lete114/hexo-minify#readme)
-在 Hexo 博客目录下,找到 `_config.yml` 文件,添加以下配置:
-没特殊需求默认即可
-```yml
-## Hexo-minify Default Config Options
-minify:
- preview: false ## 本地预览时是否压缩
- exclude: ['*.min.*']
- js:
- enable: true
- sourceMap:
- enable: false ## 生成 sourceMap
- ## 将 sourceMappingURL 插入压缩后的 js 文件,如果为 false 则需要在浏览器开发者工具中手动添加 sourceMap
- sourceMappingURL: false ## //# sourceMappingURL=xxx.js.map
- ## 详细配置: https://github.com/terser/terser#minify-options
- options: {}
- css:
- enable: true
- ## 详细配置: https://github.com/clean-css/clean-css#compatibility-modes
- options: {}
- html:
- enable: true
- ## 详细配置: https://github.com/kangax/html-minifier#options-quick-reference
- options:
- minifyJS: true # Compressed JavaScript
- minifyCSS: true # CSS Compressed
- removeComments: true # Remove the comments
- collapseWhitespace: true # Delete any extra space
- removeAttributeQuotes: true # Delete attribute quotes
- image:
- enable: true
- svg:
- enable: true
- ## 详细配置: https://github.com/imagemin/imagemin-svgo#imageminsvgooptionsbuffer
- options: {}
- jpg:
- enable: true
- ## 详细配置: https://github.com/imagemin/imagemin-jpegtran#options
- options: {}
- png:
- enable: true
- ## 详细配置: https://github.com/imagemin/imagemin-pngquant#options
- options: {}
- gif:
- enable: true
- ## 详细配置: https://www.npmjs.com/package/imagemin-gifsicle#options
- options: {}
- webp:
- enable: true
- ## 详细配置: https://github.com/imagemin/imagemin-webp#options
- options: {}
- font:
- enable: false
- ## 详细配置: https://github.com/Lete114/fontmin-spider#api
- options: {}
-```
-
-这样我们生成的代码就会被压缩 .
-在本地运行博客默认不启用压缩 `preview: false`
-
-现在我们想看看效果,就设置为 `preview: true`
-再运行
-```bash
-hexo clean && hexo g
-```
-可以看到 html 确实被压缩了
-
diff --git a/source/_posts/Deploy-a-springboot-project-to-server.md b/source/_posts/Deploy-a-springboot-project-to-server.md
index 102d1859..19ac9864 100644
--- a/source/_posts/Deploy-a-springboot-project-to-server.md
+++ b/source/_posts/Deploy-a-springboot-project-to-server.md
@@ -125,7 +125,7 @@ deb-src http://deb.debian.org/debian testing bookworm main contrib non-free non-
输入以下命令安装 `mariadb` 数据库:
```bash
-sudo apt install mariadb-server
+sudo apt install mariadb-server -y
```
### 4.3 配置数据库
diff --git a/source/_posts/Deploying-a-Web-Disk-of-Your-Own.md b/source/_posts/Deploying-a-Web-Disk-of-Your-Own.md
index 1f9f9662..8490c0a0 100644
--- a/source/_posts/Deploying-a-Web-Disk-of-Your-Own.md
+++ b/source/_posts/Deploying-a-Web-Disk-of-Your-Own.md
@@ -119,7 +119,7 @@ docker exec -it alist ./alist admin set NEW_PASSWORD
2. 添加存储:
左边栏点击 `存储`,然后点击`添加`,驱动选择 `本机存储`,点击`添加`
-1. `挂载路径`填写 `/`,意味着这次添加的存储为 `网盘根目录`。往下滑,找到 `根文件夹路径`,也就是文件的存储路径。
+3. `挂载路径`填写 `/`,意味着这次添加的存储为 `网盘根目录`。往下滑,找到 `根文件夹路径`,也就是文件的存储路径。
如果你是 **一键脚本安装** 的,就填写 `/opt/alist/files`;
如果你是 **docker-compose 安装** 的,就填 `/opt/alist/data/files`。(注意,这个是容器内的映射路径,不是宿主机的路径,参考前文的 `volumes` 配置)
@@ -140,6 +140,28 @@ docker exec -it alist ./alist admin set NEW_PASSWORD
2. 保存索引后,单击构建索引来构建索引;
3. 现在你可以通过点击页面右上角的搜索块或使用快捷键 Ctrl + K 来搜索文件。
-## 4. 高级配置
+## 4. 更新 Alist
+### 4.1 `1Panel` 一键安装
+
+打开 `1Panel` 面板,点击 `应用商店`,点击 `可升级`,找到 `Alist`,点击 `升级` 即可。
+
+### 4.2 一键脚本安装
+
+```bash
+curl -fsSL "https://alist.nn.ci/v3.sh" | bash -s update
+```
+
+### 4.3 docker-compose 安装
+
+```bash
+docker-compose pull
+docker-compose up -d
+```
+
+### 4.4 手动安装
+
+下载最新版本的 Alist,解压后替换原有文件即可。
+
+## 5. 高级配置
更多高级配置请参照官网 https://alist.nn.ci/zh/guide/
diff --git a/source/_posts/Fail2ban-installation-and-usage-tutorial.md b/source/_posts/Fail2ban-installation-and-usage-tutorial.md
index 50a84edb..6c44455c 100644
--- a/source/_posts/Fail2ban-installation-and-usage-tutorial.md
+++ b/source/_posts/Fail2ban-installation-and-usage-tutorial.md
@@ -19,12 +19,12 @@ tags:
以 Debian/Ubuntu 为例,使用以下命令安装 Fail2ban:
```bash
sudo apt update
-sudo apt install fail2ban
+sudo apt install fail2ban -y
```
需要特别注意的是,Debian 12 及以上的版本需要手动安装 `rsyslog` 来保证其正常运行:
```bash
-sudo apt install rsyslog
+sudo apt install rsyslog -y
```
原因见:[Github Issue](https://github.com/fail2ban/fail2ban/issues/3292)
diff --git a/source/_posts/How-to-Deploy-a-new-server.md b/source/_posts/How-to-Deploy-a-new-server.md
index 74a6f8ca..3e4b591b 100644
--- a/source/_posts/How-to-Deploy-a-new-server.md
+++ b/source/_posts/How-to-Deploy-a-new-server.md
@@ -19,7 +19,7 @@ date: 2024-03-01 22:25:20
我曾经也是一个新手,在部署服务器的时候遇到很多问题,不管屏幕前的你是出于何种目的:比如有业务搭建的需要;还是初入运维的小白;或者只是单纯的想折腾。我希望这篇文章大部分人看完后都能有所收获。
-本文将会介绍如何部署一台新的服务器。本文 4~7 节内容是关于服务器的安全配置,如果你只是想要部署一个简单的网站,阅读前 3 节即可。
+本文将会介绍如何部署一台新的服务器。本文 4~7 节内容是关于服务器的安全配置,如果你只是想要部署一个简单的网站,阅读前 3 节即可。**文末还有一键脚本,可以帮助你快速部署服务器,详情跳到最后一节。**
{% endnote %}
## 0. 基础的 Web 知识
@@ -58,6 +58,8 @@ date: 2024-03-01 22:25:20
而在 Linux 中,又有很多发行版,比如 Ubuntu、CentOS(近几年争议较多 不建议选择)、Debian、Fedora 等等。本文选择 **`Debian`** 作为演示,它是是最受欢迎的 Linux 发行版之一 Ubuntu 的上游,是一个非常稳定和可靠的操作系统,也通常被认为比 Ubuntu 更轻量级,因为它不包含太多附加的软件。
+一般服务器提供商都会提供多种系统,你可以根据自己的需求来选择。
+
### 0.2 什么是域名及 DNS?
购买了一台服务器之后,服务器供应商 会提供给我们服务器的 IP 地址如 `8.8.8.8`,我们可以通过这个 IP 地址来访问我们的服务器。
@@ -164,7 +166,7 @@ timedatectl
如果你是 Debian 12,那么你可以使用 `systemd-timesyncd` 来同步服务器时间。
输入以下命令来安装 `systemd-timesyncd`:
```bash
-sudo apt install systemd-timesyncd
+sudo apt install systemd-timesyncd -y
```
查看 `systemd-timesyncd` 的状态:
@@ -186,7 +188,7 @@ sudo systemctl start systemd-timesyncd
输入以下命令来安装 `ntp`:
```bash
-sudo apt install ntp
+sudo apt install ntp -y
```
查看 `ntp` 的状态:
@@ -364,7 +366,7 @@ RedHat/CentOS 系统可以选择 `firewalld` 防火墙,而 Debian/Ubuntu 系
```bash
sudo apt update
-sudo apt install ufw
+sudo apt install ufw -y
```
### 5.4 启用 ufw
@@ -408,8 +410,25 @@ sudo sysctl -p
Fail2Ban 是一个入侵检测系统框架,它可以监控服务器的日志文件,当发现有暴力破解行为时,会自动封禁攻击者的 IP 地址。可以保护电脑服务器免受暴力破解。它用 Python 编写。能够在具有本地安装的数据包控制系统或防火墙(如 iptables)接口的 POSIX 系统上运行。
+## 8. 一键脚本
+本文所讲述的内容我整理成了一键脚本,可以帮助你快速部署服务器,包括设置时区、安装 Web 服务器、SSH 安全配置、防火墙配置、禁用 ping、配置 Fail2ban 等等。 **`在使用前请最好先阅读脚本内容,以免造成不必要的损失`** 你可以根据自己的需求修改脚本内容。目前支持 Debian 12, Ubuntu 22.04
+
+使用方法:
+```bash
+wget https://raw.githubusercontent.com/mobeicanyue/init-server/main/init-server.sh
+sudo bash init-server.sh
+```
+如果你的服务器无法访问 GitHub,可以使用 jsDelivr 加速访问:
+```bash
+wget https://cdn.jsdelivr.net/gh/mobeicanyue/init-server/init-server.sh
+sudo bash init-server.sh
+```
+
+
+
+本文如有错误或者不足之处,欢迎指正。
-
+
[^1]: https://help.aliyun.com/zh/ecs/ssh-service-introduction
diff --git a/source/_posts/Nginx-installation-and-usage-tutorial.md b/source/_posts/Nginx-installation-and-usage-tutorial.md
index 467e0116..11c6c3c8 100644
--- a/source/_posts/Nginx-installation-and-usage-tutorial.md
+++ b/source/_posts/Nginx-installation-and-usage-tutorial.md
@@ -23,9 +23,8 @@ Nginx 是一个高性能的开源 Web 服务器,也可以作为反向代理服
输入以下命令安装 Nginx:
```bash
sudo apt update
-sudo apt install nginx
+sudo apt install nginx -y
```
-系统会提示是否安装,`回车` 或输入 `Y` 确认安装。
安装完成后,可以使用以下命令检查 Nginx 的版本:
```bash
diff --git a/source/_posts/Tutorial-of-Building-a-blog.md b/source/_posts/Tutorial-of-Building-a-blog.md
index d0e3a930..c36ae437 100644
--- a/source/_posts/Tutorial-of-Building-a-blog.md
+++ b/source/_posts/Tutorial-of-Building-a-blog.md
@@ -15,5 +15,4 @@ tags:
- {% post_link Use-lxgw-wenkai-in-fluid '如何在博客中使用霞鹜文楷字体' %}
### 博客优化
-- {% post_link Compress-deploy-code-size '压缩部署的代码' %}
- {% post_link Blog-seo-optimization '博客 SEO 优化' %}
diff --git a/source/_posts/Umami-installation-and-usage-tutorial.md b/source/_posts/Umami-installation-and-usage-tutorial.md
index 40399bad..218d1732 100644
--- a/source/_posts/Umami-installation-and-usage-tutorial.md
+++ b/source/_posts/Umami-installation-and-usage-tutorial.md
@@ -68,7 +68,7 @@ yarn start
{% endfold %}
-{% fold info @dokcer-compose 安装 %}
+{% fold info @docker-compose 安装 %}
下载官方的 docker-compose.yml 文件:
https://github.com/umami-software/umami/blob/master/docker-compose.yml