Linux安装qBittorrent-Enhanced-Edition

Github 下载可执行文件 1 2 3 4 5 6 7 8 9 10 11 12 #x86_64 download_url=$(curl -s https://api.github.com/repos/c0re100/qBittorrent-Enhanced-Edition/releases/latest | jq -r '.assets[] | select(.name | test("qbittorrent-enhanced-nox_x86_64-linux-musl_static.zip")) | .browser_download_url') && \ curl -L $download_url -o /usr/bin/qbittorrent-nox.zip && \ unzip /usr/bin/qbittorrent-nox.zip -d /usr/bin/ && \ chmod +x /usr/bin/qbittorrent-nox && \ rm /usr/bin/qbittorrent-nox.zip #arm64 download_url=$(curl -s https://api.github.com/repos/c0re100/qBittorrent-Enhanced-Edition/releases/latest | jq -r '.assets[] | select(.name | test("qbittorrent-enhanced-nox_aarch64-linux-musl_static.zip")) | .browser_download_url') && \ curl -L "$download_url" -o /usr/bin/qbittorrent-nox.zip && \ unzip /usr/bin/qbittorrent-nox.zip -d /usr/bin/ && \ chmod +x /usr/bin/qbittorrent-nox && \ rm /usr/bin/qbittorrent-nox.zip 创建system服务 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 cat > /etc/systemd/system/qbittorrent.service <<EOF [Unit] Description=qBittorrent Daemon Service After=network-online.target [Service] Type=simple User=root Group=root UMask=007 ExecStart=/usr/bin/qbittorrent-nox ExecStop=/bin/kill -s SIGTERM $MAINPID Restart=on-failure [Install] WantedBy=multi-user.target EOF 启动 1 2 3 systemctl enable qbittorrent systemctl start qbittorrent systemctl status qbittorrent # 查看登录密码,默认登录端口8080 下载完后上传网盘 1 2 3 4 #创建日志文件夹 mkdir -p /root/rclone_logs #下载完成后执行命令,bt:/bt自行修改为你设置rclone remote名和上传到网盘的路径 rclone move "%F" "bt:/bt/%N" --create-empty-src-dirs --transfers=4 --checkers=4 Nginx反代 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #安装所需程序 sudo apt install certbot python3-certbot-nginx python3-certbot-dns-cloudflare nginx #手动编辑 sudo nano /etc/nginx/sites-available/bt #这里是nginx配置路径为conf.d的配置,下面启用配置命令不用 sudo nano /etc/nginx/conf.d/bt.conf #启用配置 sudo ln -s /etc/nginx/sites-available/bt /etc/nginx/sites-enabled/ #从Cloudflare获取区域DNS API sudo nano /etc/letsencrypt/cloudflare.ini dns_cloudflare_api_token = 你的API #赋予权限 sudo chmod 600 /etc/letsencrypt/cloudflare.ini #使用CF-DNS申请证书,你不想关小黄云用这个,全程y就行 sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini -d example.com #直接申请证书,上面的申请完后可以用这个命令自动配置HTTPS,选1 sudo certbot --nginx -d example.com 配置示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 server { listen 80; # 端口可以随意修改 listen [::]:80; # IPv6 监听,同样可修改 #server_name _; server_name example.com; # 也可以写多个域名,用空格分隔 location / { proxy_pass http://127.0.0.1:8080; # 代理到本地 8080 端口 proxy_set_header Host $host; # 保留原始 Host 头 proxy_set_header X-Real-IP $remote_addr; # 真实客户端 IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # 协议(http/https) } } 内存占用解决办法 在设置高级中将磁盘 IO 类型设置为遵循 POSIX

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 606字 | 阅读时长: 2分钟 | Beiyuan

Linux创建python虚拟环境解决依赖问题

1 sudo apt update && sudo apt install python3 -y #安装python 1 2 3 4 5 sudo apt install python3-venv -y #安装虚拟环境 mkdir /opt/env && cd /opt/env #创建文件夹单独存放相关文件和配置,也可以不创建 python3 -m venv komga #创建虚拟环境,env是你虚拟环境的名称,可以自定义,这里创建虚拟环境同时会创建一个文件夹 source komga/bin/activate #激活虚拟环境,这里的env同理,需要和上面一致 deactivate #关闭虚拟环境

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 148字 | 阅读时长: 1分钟 | Beiyuan

Linux修改DNS

DNS列表 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 # Cloudflare DNS # IPv4 1.1.1.1 1.0.0.1 # IPv6 2606:4700:4700::1111 2606:4700:4700::1001 # Google DNS # IPv4 8.8.8.8 8.8.4.4 # IPv6 2001:4860:4860::8888 2001:4860:4860::8844 # 阿里云公共DNS # IPv4 223.5.5.5 223.6.6.6 # IPv6 2400:3200::1 2400:3200:baba::1 # 腾讯DNSPod公共DNS # IPv4 119.29.29.29 # IPv6 2402:4e00:: 方法一:Systemd-resolved 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #查看是否安装 sudo systemctl status systemd-resolved #没有安装执行命令安装并启动 sudo apt update sudo apt install systemd-resolved -y sudo systemctl enable systemd-resolved && sudo systemctl start systemd-resolved #修改DNS sudo nano /etc/systemd/resolved.conf #示例 [Resolve] DNS=8.8.8.8 1.1.1.1 FallbackDNS=8.8.4.4 #修改完后退出,重新启动 sudo systemctl restart systemd-resolved 报错masked解决方法 1 2 3 4 5 6 7 8 9 10 11 12 13 #输入下面的命令 sudo systemctl unmask systemd-resolved #再次重启 sudo systemctl restart systemd-resolved #查看是否修改成功 resolvectl status #查看是否软链接成功 ls -l /etc/resolv.conf #上面命令示例 lrwxrwxrwx 1 root root 32 Feb 11 2024 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf #不一样执行下面的命令后再次查看 sudo rm /etc/resolv.conf sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf 方法二:Resolved 1 2 3 4 5 sudo apt update sudo apt install resolvconf sudo nano /etc/resolv.conf #防止被修改 sudo chattr +i /etc/resolv.conf

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 350字 | 阅读时长: 1分钟 | Beiyuan

Nginx搭配php部署随机图片API

Github 准备 1 2 #安装所需程序 sudo apt install nginx php7.4-fpm php7.4-mysql php7.4-fpm php7.4-mysql php7.4-cli php7.4-opcache certbot python3-certbot-nginx python3-certbot-dns-cloudflare 创建Index.php文件 这里只需要修改路径 主路径 1 2 cd /var/www/html nano index.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 <?php $pcPath = '/landscape';#这里的路径自行修改 $mobilePath = '/portrait';#这里的路径自行修改 // 函数:从目录中获取图片列表 function getImagesFromDir($path) { $images = array(); if ($img_dir = @opendir($path)) { while (false !== ($img_file = readdir($img_dir))) { // 匹配 webp、jpg、jpeg、png、gif 格式的图片 if (preg_match("/\.(webp|jpg|jpeg|png|gif)$/i", $img_file)) { $images[] = $img_file; } } closedir($img_dir); } return $images; } // 函数:生成完整的图片路径 function generateImagePath($path, $img) { return $path . '/' . $img; } // 检测用户代理以区分手机和电脑访问 $userAgent = $_SERVER['HTTP_USER_AGENT']; $isMobile = preg_match('/(android|iphone|ipad|ipod|blackberry|windows phone)/i', $userAgent); // 根据访问设备设置图片路径 if ($isMobile) { $path = $mobilePath; } else { $path = $pcPath; } // 缓存图片列表 $imgList = getImagesFromDir($path); // 从列表中随机选择一张图片 shuffle($imgList); $img = reset($imgList); // 获取图片的格式 $img_extension = pathinfo($img, PATHINFO_EXTENSION); // 根据图片的格式设置 Content-Type switch ($img_extension) { case 'webp': header('Content-Type: image/webp'); break; case 'jpg': case 'jpeg': header('Content-Type: image/jpeg'); break; case 'png': header('Content-Type: image/png'); break; case 'gif': header('Content-Type: image/gif'); break; // 添加其他格式的处理方式 // case 'bmp': // header('Content-Type: image/bmp'); // break; } // 生成完整的图片路径 $img_path = generateImagePath($path, $img); // 直接输出所选的随机图片 readfile($img_path); ?> PC路径 1 2 mkdir /var/www/html/pc && cd /var/www/html/pc nano index.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 <?php $pcPath = '../landscape';#这里的路径自行修改 // 函数:从目录中获取图片列表 function getImagesFromDir($path) { $images = array(); if ($img_dir = @opendir($path)) { while (false !== ($img_file = readdir($img_dir))) { // 匹配 webp、jpg、jpeg、png、gif 格式的图片 if (preg_match("/\.(webp|jpg|jpeg|png|gif)$/i", $img_file)) { $images[] = $img_file; } } closedir($img_dir); } return $images; } // 函数:生成完整的图片路径 function generateImagePath($path, $img) { return $path . '/' . $img; } // 设置图片路径为 landscape $path = $pcPath; // 缓存图片列表 $imgList = getImagesFromDir($path); // 从列表中随机选择一张图片 shuffle($imgList); $img = reset($imgList); // 获取图片的格式 $img_extension = pathinfo($img, PATHINFO_EXTENSION); // 根据图片的格式设置 Content-Type switch ($img_extension) { case 'webp': header('Content-Type: image/webp'); break; case 'jpg': case 'jpeg': header('Content-Type: image/jpeg'); break; case 'png': header('Content-Type: image/png'); break; case 'gif': header('Content-Type: image/gif'); break; // 添加其他格式的处理方式 // case 'bmp': // header('Content-Type: image/bmp'); // break; } // 生成完整的图片路径 $img_path = generateImagePath($path, $img); // 直接输出所选的随机图片 readfile($img_path); ?> Mobile路径 1 2 mkdir /var/www/html/mobile && cd /var/www/html/mobile nano index.php 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 <?php $pcPath = '../portrait';#这里的路径自行修改 // 函数:从目录中获取图片列表 function getImagesFromDir($path) { $images = array(); if ($img_dir = @opendir($path)) { while (false !== ($img_file = readdir($img_dir))) { // 匹配 webp、jpg、jpeg、png、gif 格式的图片 if (preg_match("/\.(webp|jpg|jpeg|png|gif)$/i", $img_file)) { $images[] = $img_file; } } closedir($img_dir); } return $images; } // 函数:生成完整的图片路径 function generateImagePath($path, $img) { return $path . '/' . $img; } // 设置图片路径为 portrait $path = $pcPath; // 缓存图片列表 $imgList = getImagesFromDir($path); // 从列表中随机选择一张图片 shuffle($imgList); $img = reset($imgList); // 获取图片的格式 $img_extension = pathinfo($img, PATHINFO_EXTENSION); // 根据图片的格式设置 Content-Type switch ($img_extension) { case 'webp': header('Content-Type: image/webp'); break; case 'jpg': case 'jpeg': header('Content-Type: image/jpeg'); break; case 'png': header('Content-Type: image/png'); break; case 'gif': header('Content-Type: image/gif'); break; // 添加其他格式的处理方式 // case 'bmp': // header('Content-Type: image/bmp'); // break; } // 生成完整的图片路径 $img_path = generateImagePath($path, $img); // 直接输出所选的随机图片 readfile($img_path); ?> 反代开启HTTPS 1 2 3 4 #清空默认配置 > /etc/nginx/sites-available/default #手动编辑默认配置 sudo nano /etc/nginx/sites-available/default 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 server { listen [::]:8080; listen 8080; server_name example.com; # 替换为你的域名以便下面申请域名 root /var/www/html; # 设置网站根目录 # 默认首页是 index.php 或其他文件(根据你的需求) index index.php index.html index.htm; # 处理根目录请求,直接返回根目录下的文件(如果存在) location / { try_files $uri $uri/ /index.php?$query_string; } # 处理 PHP 文件 location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # 防止访问 .ht 文件(如果有) location ~ /\.ht { deny all; } } 1 2 3 4 #测试Nginx配置 sudo nginx -t #重新加载Nginx配置 sudo systemctl reload nginx 现在可以访问ip:8080查看效果 ...

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 2278字 | 阅读时长: 5分钟 | Beiyuan

Rclone挂载Onedrive

获取 client_id 首先访问 Microsoft Azure应用注册,登录账号后点击应用注册 点击注册后可以看到你的应用的相关信息,复制好 应用程序 (客户端) ID,这个就是 client_id 获取 client_secret 依次点击证书和密码,新客户端密码,在截止期限中将时间选择为最长(即两年)然后就可以看见值和机密 ID,我们只需要记录下 值 就可以,这个就是 client_secret 。 ...

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 228字 | 阅读时长: 1分钟 | Beiyuan

Realm端口转发

获取执行文件 1 2 3 4 5 6 7 sudo mkdir -p /root/realm && \ curl -s https://api.github.com/repos/zhboner/realm/releases/latest | \ jq -r '.assets[] | select(.name | test("realm-x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url' | \ wget -O /root/realm/realm.tar.gz && \ sudo tar -xvf /root/realm/realm.tar.gz -C /root/realm && \ sudo chmod +x /root/realm/realm && \ sudo rm /root/realm/realm.tar.gz #可执行文件位于/root/realm 新建 config.toml 文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 cat > /root/realm/config.toml <<EOF [network] no_tcp = false use_udp = true [[endpoints]] listen = "[::]:443" #监听v6,你的中转机,端口自行修改,以下类似 remote = "0.0.0.0:443 #监听v4,你的落地机 [[endpoints]] listen = "0.0.0.0:80" #监听v4,你的中转机 remote = "[::]:80#监听v6,你的落地机 EOF 写入Service 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 cat > /etc/systemd/system/realm.service <<EOF [Unit] Description=realm After=network-online.target Wants=network-online.target systemd-networkd-wait-online.service [Service] Type=simple User=root Restart=on-failure RestartSec=5s DynamicUser=true WorkingDirectory=/root ExecStart=/root/realm/realm -c /root/realm/config.toml [Install] WantedBy=multi-user.target EOF 启动服务 1 2 3 4 5 systemctl daemon-reload systemctl enable realm systemctl start realm systemctl restart realm systemctl status realm

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 261字 | 阅读时长: 1分钟 | Beiyuan

服务器部署Hugo

Github 安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # 删除旧版 Hugo which hugo &>/dev/null && sudo rm -f $(which hugo) # 下载并安装最新版本的 Hugo curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest \ | grep "browser_download_url" \ | grep -E "hugo_extended_.*Linux-64bit\.tar\.gz" \ | grep -vE "\.with" \ | cut -d '"' -f 4 | head -n 1 \ | xargs wget -O hugo.tar.gz && \ tar -xzf hugo.tar.gz && \ sudo mv hugo /usr/local/bin/ && \ rm -f hugo.tar.gz LICENSE* README.md # 固定版本 wget https://github.com/gohugoio/hugo/releases/download/v0.147.2/hugo_extended_0.147.2_Linux-64bit.tar.gz -O hugo.tar.gz && \ tar -xzf hugo.tar.gz && \ sudo mv hugo /usr/local/bin/ && \ rm -rf hugo.tar.gz LICENSE* README.md 安装主题 1 2 3 4 5 6 7 8 9 10 # 创建一个名为 blog 的新 Hugo 站点 hugo new site /opt/blog --format yaml # 进入站点目录 cd /opt/blog # 初始化 git 仓库(推荐,方便管理主题子模块) apt install git git init # 添加主题为子模块 git submodule add https://github.com/adityatelange/hugo-PaperMod.git themes/PaperMod git submodule update --remote --merge 默认配置示例 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 baseURL: "https:example.com" # 网站的基础 URL,部署到子路径需调整此项 title: Beiyuan # 网站标题 theme: PaperMod # 使用的主题名称(已安装的主题文件夹名) languageCode: zh # 网站默认语言(中文) defaultContentLanguage: zh # 默认内容语言 hasCJKLanguage: true # 是否启用对中日韩语言优化(统计字数、阅读时间等更准确) pagination: pagerSize: 10 # 每页最多显示 10 篇文章 enableRobotsTXT: true # 启用 robots.txt 文件(搜索引擎爬虫指引) buildDrafts: false # 不构建草稿文章 buildFuture: false # 不构建发布日期在未来的文章 buildExpired: false # 不构建已过期的文章 minify: disableXML: true # 不压缩生成的 XML 文件 #minifyOutput: true # 压缩 HTML 输出 params: env: production # 环境变量,生产环境时可启用 GA、SEO 等 title: Beiyuan # 站点标题(与上面重复,但为主题使用) description: "Share" # 网站描述 keywords: [资源分享] # 关键词,SEO 使用 author: Beiyuan # 作者名称 DateFormat: "January 2, 2006" # 日期格式(文章时间显示格式) defaultTheme: auto # 默认主题:auto(跟随系统)、dark、light disableThemeToggle: false # 是否禁用切换明暗模式按钮 ShowReadingTime: true # 显示文章阅读时间 ShowPostNavLinks: true # 显示上一篇/下一篇导航链接 ShowBreadCrumbs: true # 显示面包屑导航 ShowCodeCopyButtons: false # 是否显示“复制代码”按钮 ShowWordCount: true # 显示文章字数 ShowRssButtonInSectionTermList: true # 在分类、标签页面显示 RSS 按钮 UseHugoToc: true # 使用 Hugo 内置目录而非主题自带目录 disableSpecial1stPost: false # 是否禁用首页首篇特殊展示样式 disableScrollToTop: false # 是否禁用回到顶部按钮 comments: false # 全局禁用评论 hidemeta: false # 是否隐藏 meta 信息(作者、时间等) hideSummary: false # 是否隐藏摘要 showtoc: false # 是否默认显示目录 tocopen: false # 是否默认展开目录 assets: # disableHLJS: true # 是否禁用 highlight.js(如果用的是 Chroma 可禁用) # disableFingerprinting: true # 是否禁用静态资源指纹(可选) favicon: "/favicon.ico" # 网站图标路径(放置在 static/ 下) favicon16x16: "/favicon-16x16.png" favicon32x32: "/favicon-32x32.png" apple_touch_icon: "/apple-touch-icon.png" safari_pinned_tab: "/favicon.ico" label: text: "Beiyuan" # 左上角 Logo 文字 icon: /apple-touch-icon.png # Logo 图标路径 iconHeight: 35 # Logo 高度 # 首页介绍卡片 homeInfoParams: Title: "Beiyuan Shares" # 首页介绍标题 Content: A place where I share the things I want to share # 首页介绍内容 cover: hidden: true # 是否在结构化数据中隐藏封面 hiddenInList: true # 是否在列表页隐藏封面图 hiddenInSingle: true # 是否在单页隐藏封面图 # 搜索相关配置(使用 Fuse.js 本地搜索) # Fuse.js 配置说明:https://fusejs.io/api/options.html fuseOpts: isCaseSensitive: false shouldSort: true location: 0 distance: 1000 threshold: 0.4 minMatchCharLength: 0 limit: 10 keys: ["title", "permalink", "summary", "content"] menu: main: - identifier: archives # 归档页面菜单项 name: 归档 url: /archives/ weight: 10 - identifier: tags # 标签页面菜单项 name: 标签 url: /tags/ weight: 20 - identifier: search # 搜索页面菜单项 name: 搜索 url: /search/ weight: 30 # 使用 Hugo 的语法高亮器(Chroma) # 更多配色方案见:https://xyproto.github.io/splash/docs/all.html pygmentsUseClasses: true # 使用 CSS 类进行高亮(建议开启,便于主题样式控制) markup: highlight: noClasses: false # 使用 CSS 类而非内联样式(false 推荐) # anchorLineNos: true # 是否为每一行添加锚点(方便链接到指定代码行) # codeFences: true # 启用 ``` 代码块支持(建议开启) # guessSyntax: true # 启用语言猜测(不指定语言时尝试自动识别) # lineNos: true # 显示代码行号 # style: monokai # 设置代码高亮风格,如:monokai、dracula、github、solarized 等 默认文章头示例 1 2 3 4 5 6 7 8 9 10 11 12 13 --- auther: Beiyuan author: Beiyuan categories: - 自建折腾 date: '2025-05-06T14:26:29' draft: false lastmod: '2025-05-06T14:26:29' tags: - Tools title: 服务器部署Hugo --- 创建文章并启动 1 2 3 4 #创建新文章 hugo new posts/my-new-post.md #启动,创建完成后就和hugo脱离了,hugo只需要写文章build就行了 hugo --environment production --minify --cleanDestinationDir Nginx反代 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #安装所需程序 sudo apt install certbot python3-certbot-nginx python3-certbot-dns-cloudflare nginx #手动编辑 sudo nano /etc/nginx/sites-available/hugo #启用配置 sudo ln -s /etc/nginx/sites-available/hugo /etc/nginx/sites-enabled/ #从Cloudflare获取区域DNS API sudo nano /etc/letsencrypt/cloudflare.ini dns_cloudflare_api_token = 你的API #赋予权限 sudo chmod 600 /etc/letsencrypt/cloudflare.ini #使用CF-DNS申请证书,你不想关小黄云用这个,全程y就行 sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini -d example.com #替换为你的域名 #直接申请证书,上面的申请完后可以用这个命令自动配置HTTPS,选1 sudo certbot --nginx -d example.com #替换为你的域名 #这里是把hugo生成的public软链接到nginx目录 sudo ln -s /opt/blog/public /var/www/html/hugo 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 server { listen 80; listen [::]:80; server_name example.com; # 替换为您的域名或 IP 地址 root /var/www/html/hugo; # Hugo 网站的 public 目录路径 (确保这个路径存在并指向 Hugo 的输出目录) index index.html; # Hugo 路由兼容(archives、tags 等路径支持) location / { try_files $uri $uri/ /index.html; } # 启用 gzip 压缩 gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; # 缓存静态资源 location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|svg|woff2?|ttf|eot|otf|json|webp)$ { expires 30d; access_log off; add_header Cache-Control "public"; } # 强化安全头部 add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always; # 拒绝访问隐藏文件(如 .git) location ~ /\. { deny all; } } 启用归档和搜索 1 2 3 cd /opt/blog/content nano archives.md nano search.md 1 2 3 4 5 6 7 8 9 10 11 12 13 --- auther: Beiyuan author: Beiyuan categories: - 自建折腾 date: '2025-05-06T14:26:29' draft: false lastmod: '2025-05-06T14:26:29' tags: - Tools title: 服务器部署Hugo --- 1 2 3 4 5 6 7 8 9 10 11 12 13 --- auther: Beiyuan author: Beiyuan categories: - 自建折腾 date: '2025-05-06T14:26:29' draft: false lastmod: '2025-05-06T14:26:29' tags: - Tools title: 服务器部署Hugo --- 标签分类和文章页面修改中文 要将标签和分类等页面改为中文需要在对应文件夹下添加 _index.md 文件。 ...

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 2261字 | 阅读时长: 5分钟 | Beiyuan

个人大模型API管理工具UNI-API部署

Github 面板 配置生成 1 2 3 mkdir -p /opt/uniapi && cd /opt/uniapi nano api.yaml nano docker-compose.yaml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 services: #主程序 uniapi: image: yym68686/uni-api:latest restart: unless-stopped ports: - "8001:8000" volumes: - ./api.yaml:/home/api.yaml - ./data:/home/data #面板服务 uniapi-frontend: image: ghcr.io/melosbot/uni-api-status:latest restart: unless-stopped ports: - "3000:3000" environment: - NODE_ENV=production - PORT=3000 # 以下为容器内的路径,与 volumes 挂载点对应 - API_YAML_PATH=/app/config/api.yaml - STATS_DB_PATH=/app/data/stats.db volumes: # 将宿主机的 api.yaml 挂载到容器内,需要【读写】权限 - ./api.yaml:/app/config/api.yaml # 将宿主机包含 stats.db 的目录挂载到容器内,建议只读【:ro】 - ./data:/app/data:ro 1 docker compose up -d 最小可启动配置模板 1 2 3 4 5 6 7 8 providers: - provider: provider_name # 服务提供商名称, 如 openai、anthropic、gemini、openrouter,随便取名字,必填 base_url: https://api.your.com/v1/chat/completions # 后端服务的API地址,必填 api: sk-YgS6GTi0b4bEabc4C # 提供商的API Key,必填,自动使用 base_url 和 api 通过 /v1/models 端点获取可用的所有模型。 # 这里可以配置多个提供商,每个提供商可以配置多个 API Key,每个提供商可以配置多个模型。 api_keys: - api: sk-Pkj60Yf8JFWxfgRmXQFWyGtWUddGZnmi3KlvowmRWpWpQxx # API Key,用户请求 uni-api 需要 API key,必填 # 该 API Key 可以使用所有模型,即可以使用 providers 下面设置的所有渠道里面的所有模型,不需要一个个添加可用渠道。

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 409字 | 阅读时长: 1分钟 | Beiyuan

利用CF搭建DDNS

把域名接入cloudflare 打开cloudflare,登陆账号添加网站按照提示操作 获取Global API Key 访问 https://dash.cloudflare.com/profile在页面下方找到 Global API Key,点击右侧的 View 查看 Key,并保存下来 ,在页面下方找到 Global API Key,点击右侧的 View 查看 Key,并保存下来 ...

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 432字 | 阅读时长: 1分钟 | Beiyuan

手搓Nginx反代开启HTTPS

Nginx Documents 安装Nginx 1. 安装依赖项 1 2 3 4 5 #我只用Debian和Ubuntu,需要centos的自行去nginx官网查找 #Debian sudo apt install curl gnupg2 ca-certificates lsb-release debian-archive-keyring -y #Ubuntu sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring -y 2 . 导入 Nginx 官方签名密钥 1 2 curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \ | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null 3 . 验证密钥 1 gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg 应看到如下输出中的指纹: ...

创建: 2025年09月03日 | 更新: 2025年12月04日 | 字数: 686字 | 阅读时长: 2分钟 | Beiyuan