Files
nexus/wiki/sources/ubuntu-安装-frp-0-65-0-x86_64-操作笔记.md
2026-04-22 04:03:04 +08:00

128 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Ubuntu 安装 FRP 0.65.0x86_64操作笔记"
type: source
tags: [frp, frpc, ubuntu, systemd, x86_64]
date: 2026-04-14
---
## Source File
- [[raw/Home Office/Ubuntu 安装 FRP 0.65.0x86_64操作笔记.md]]
## Summary (用中文描述)
- **核心主题**:在 Ubuntu Server 24.04x86_64/amd64上安装配置 FRP 0.65.0 内网穿透客户端,实现通过公网 VPS 远程访问本地 SSH 服务
- **问题域**Linux 服务器运维、内网穿透、服务管理
- **方法/机制**:通过 FRPfrpc客户端连接远程 VPSfrps建立反向隧道通过 systemd 实现开机自启和进程管理
- **结论/价值**:提供完整的 Ubuntu Server FRP 运维手册,包含 systemd 服务管理、最佳实践和故障排查指南;与 Mac Mini ARM64 版本形成完整的多平台覆盖
## Key Claims (用中文描述)
- Ubuntu Server 24.04 需手动创建 `/opt/frp` 安装目录
- FRP 0.65.0 使用 TOML 配置文件格式frpc.toml
- systemd 是 Ubuntu/Linux 生产环境推荐的服务管理方式
- 通过软链接symlink策略可实现版本无缝切换无需修改 systemd 配置
- journald 日志是 systemd 环境的推荐日志管理方案
## Key Quotes
> "login to server success" — frpc 成功连接 frps 的日志标志
> "proxy added: ssh" — SSH 代理成功注册的日志标志
> "Restart=on-failure + RestartSec=10" — systemd 服务自动恢复配置,确保服务中断后自动重启
> "升级时只需要切换 symlink无需修改 systemd 配置" — 软链接策略的核心价值
## Key Concepts
- [[内网穿透]]:通过反向隧道技术,使公网用户能够访问处于 NAT 或防火墙后的内网服务
- [[frp]]Fast Reverse Proxy开源内网穿透工具包含 frps服务端和 frpc客户端
- [[TCP隧道]]:基于 TCP 协议的端口转发机制,将本地端口映射到远程服务器
- [[systemd]]Linux 系统和服务管理器Ubuntu Server 的默认初始化系统,用于管理 FRP 客户端开机自启
- [[软链接策略]]:通过 `/opt/frp/current` 软链接指向具体版本目录,实现版本切换无需修改 systemd 配置
## Key Entities
- [[VPS]]:公网虚拟专用服务器,运行 frps 作为内网穿透的中转站IP: 192.227.222.142,端口: 7000
- [[frpc]]FRP 客户端程序,运行在 Ubuntu Server 上,建立与 frps 的反向隧道
- [[frps]]FRP 服务端程序,运行在 VPS 上,监听 7000 端口,接收 frpc 连接并转发请求
- [[Ubuntu Server]]Canonical 维护的 Linux 服务器操作系统,本次安装目标为 24.04 LTS 版本
- [[systemd]]Linux 系统和服务管理器Ubuntu Server 24.04 的默认初始化系统
## Connections
- [[Ubuntu Server]] ← runs_on ← [[frpc]]
- [[VPS]] ← runs_on ← [[frps]]
- [[frpc]] ← creates_tunnel ← [[frps]]
- [[systemd]] ← manages ← [[frpc]] 进程生命周期
- [[内网穿透]] ← enables ← [[远程SSH访问]]
- [[软链接策略]] ← simplifies ← [[版本升级]](无需修改 systemd 配置)
## Contradictions
- 与 [[mac-mini-安装-frp-0-65-0-arm64-操作笔记]] 存在**平台差异**
- 差异点服务管理机制Ubuntu 用 systemdmacOS 用 launchd
- 当前观点systemd 是 Linux 生产环境标准配置简单service 文件 + systemctl 命令)
- 对方观点launchd 是 macOS 原生方案,通过 plist + launchctl 管理
- 结论:两个平台均推荐各自原生的服务管理机制,不存在优劣之分,只是生态差异
## Environment Details
| 项目 | 内容 |
|------|------|
| 系统 | Ubuntu Server 24.04 LTS |
| 架构 | x86_64 (amd64) |
| 软件 | FRP 0.65.0 |
| 安装目录 | `/opt/frp/frp_0.65.0_linux_amd64` |
| 客户端程序 | `frpc` |
| 配置文件 | `frpc.toml` |
| 服务管理 | systemd |
| frps服务器 | 192.227.222.142:7000 |
| frps认证token | your_token_here |
| frps映射端口 | 6000本地 SSH 22 → 远程 6000|
## Installation Steps
1. 创建安装目录:`sudo mkdir -p /opt/frp && sudo chown -R $(whoami) /opt/frp`
2. 下载 x86_64 版本:`wget https://github.com/fatedier/frp/releases/download/v0.65.0/frp_0.65.0_linux_amd64.tar.gz`
3. 解压:`tar -xzf frp_0.65.0_linux_amd64.tar.gz`
4. 配置 frpc.toml设置 serverAddr、serverPort、auth.token 和 [[proxies]] 数组
5. 测试运行:`./frpc -c frpc.toml`,验证 "login to server success"
6. 创建 systemd 服务文件:`/etc/systemd/system/frpc.service`
7. 启用开机自启:`sudo systemctl daemon-reload && sudo systemctl enable --now frpc`
## Configuration Reference
```toml
serverAddr = "192.227.222.142"
serverPort = 7000
[auth]
token = "your_token_here"
[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 6000
```
## systemd Service Template
```ini
[Unit]
Description=frp client
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/opt/frp/frp_0.65.0_linux_amd64/frpc -c /opt/frp/frp_0.65.0_linux_amd64/frpc.toml
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
```
## Maintenance Commands
- 查看状态:`sudo systemctl status frpc`
- 查看日志:`sudo journalctl -u frpc -f`
- 重启服务:`sudo systemctl restart frpc`
- 停止服务:`sudo systemctl stop frpc`
- 禁用开机自启:`sudo systemctl disable frpc`
## Best Practices
1. **软链接策略**:创建 `/opt/frp/current` → 具体版本目录的软链接systemd 配置使用 current 路径
2. **日志管理**:使用 journaldjournalctl管理日志支持实时流式查看和历史记录
3. **配置验证**:使用 `./frpc validate -c frpc.toml` 验证配置文件语法后再重启服务
4. **防火墙检查**:确保 frps 服务器端口7000和映射端口6000在防火墙中开放
5. **版本管理**:多版本并存于 `/opt/frp/`通过软链接切换systemd 配置保持不变