SanYeCao-blog/src/blog/post-2.md

194 lines
4.2 KiB
Markdown
Raw Normal View History

2026-03-24 23:40:19 +00:00
---
2026-03-25 16:46:48 +00:00
title: "教程树莓派5安装sunshine实现局域网串流"
pubDate: 2025-04-21
description: '在树莓派上安装sunshine'
author: "三叶"
image:
url: "https://files.seeusercontent.com/2026/03/25/t2zJ/pasted-image-1774456500701.webp"
alt: "img"
tags: ["树莓派", "Linux", "教程"]
2026-03-24 23:40:19 +00:00
---
2026-03-25 16:46:48 +00:00
**This blog post also has an English version, click here: [(tutorial) How to Stream Via Sunshine on Your Raspberry Pi 5](https://blog.cloverta.top/archives/203)**
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
## 0.在开始之前
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
我们需要理解的是树莓派5是arm64架构处理器需要看准安装的sunshine版本。
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
并且Linux环境下配置sunshine会稍微有些麻烦不过不会太麻烦大概
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
那我们开始吧。
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
## 1.安装sunshine
2026-03-24 23:40:19 +00:00
2026-03-25 16:46:48 +00:00
链接:[LizardByte: Sunshine for Linux](https://github.com/LizardByte/Sunshine/releases)
树莓派使用的是基于Debian发行版的操作系统所以我们需要找到 **sunshine-debian-bookworm-arm64.deb 。**单击下载
![pasted-image-1774456393003.webp](https://files.seeusercontent.com/2026/03/25/r9Ot/pasted-image-1774456393003.webp)
将下载好的deb安装包传入树莓派或者直接在树莓派中下载也一样
进入安装包所在的目录,并在终端输入
```
dpkg -i sunshine-debian-bookworm-arm64.deb
```
```
dpkg -i sunshine-debian-bookworm-arm64.deb
```
以手动安装sunshine具体包名请以你的文件名为准。
如果出现缺少依赖的问题,输入
```
sudo apt-get install -f
```
```
sudo apt-get install -f
```
安装缺失的依赖。安装好依赖后再安装一次sunshine的deb安装包。
终端输入
```
sunshine
```
```
sunshine
```
并回车,检查是否安装成功。
**注意:**到这一步sunshine很有可能是没法启动的因为缺失必要的配置。
那么紧接着下一步
## 2.配置树莓派
### ①更新系统
确保树莓派的软件是全新的,运行以下命令:
```
sudo apt update && sudo apt full-upgrade -y
```
```
sudo apt update && sudo apt full-upgrade -y
```
这一步是必要的,因为 Wayland 的支持可能依赖于系统更新。
### ②启用Wayland支持
在较新的 Raspberry Pi OS 版本中Wayland 已默认启用。但如果你使用sunshine时出现报错
> Error: Environment variable WAYLAND\_DISPLAY has not been defined
 那么首先修改启动配置:
```
sudo nano /boot/firmware/config.txt
```
```
sudo nano /boot/firmware/config.txt
```
打开启动配置文件,在最后面添加两行
```
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
```
```
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
```
以启动硬件加速,保存并退出后重启设备。
之后,输入
```
sudo raspi-config
```
```
sudo raspi-config
```
进入树莓派系统配置,依次选择
>   6 Advanced Options
>
>   A6 Wayland 
>
>   W3 Labwc 这是树莓派推荐的 Wayland 合成器)
 配置完成后重启。
打开VNC远程桌面切记不要用ssh终端在终端中输入
```
echo $XDG_SESSION_TYPE
```
```
echo $XDG_SESSION_TYPE
```
如果输出结果是wayland说明设定成功。
### ③启用avahi-daemon
如果出现报错
> Error: Failed to create client: Daemon not running
 在终端中输入
```
systemctl enable avahi-daemon
```
```
systemctl enable avahi-daemon
```
## 3.启动sunshine
非常好!现在应当完成了所有配置!
在VNC远程桌面的终端输入
```
sunshine
```
```
sunshine
```
以启动sunshine。
**注意:**如果你没有安装虚拟显示器需要保证树莓派至少开启了一个桌面无论是VNC还是连接物理显示器。最好不要通过ssh终端启动sunshine。
成功的话应该能在终端看到
![pasted-image-1774456462002.webp](https://files.seeusercontent.com/2026/03/25/Cn4m/pasted-image-1774456462002.webp)
ctrl+鼠标左键单击https://localhost:47990通过浏览器访问sunshine的Web UI我们就能看到熟悉的界面啦。
![pasted-image-1774456481966.webp](https://files.seeusercontent.com/2026/03/25/Xk6z/pasted-image-1774456481966.webp)
之后的步骤和Windows端sunshine一样连接就可以了
![pasted-image-1774456500701.webp](https://files.seeusercontent.com/2026/03/25/t2zJ/pasted-image-1774456500701.webp)