Navidrome是开源的音乐服务器,它可以把硬盘的音乐文件以流媒体的方式呈现出来,就可以在任何的浏览器收听自己的音乐,并兼容subsonic API接口,也可以在第三方的客户端,最终在PC和手机,平板上实现全平台的音乐输出。

这里我在自己的万由NAS上自建一个开源播放器,我这里尝试了subsonicNavidrome这两款开源的程序,两款我都安装了,在使用一段时间后还是navidrome的服务,主要是UI界面比较讨好我,性能方面都差不多。

大概的安装方式,看一下官方文档,这里我使用Debian来进行安装,嫌麻烦可以使用docker方式安装。

安装方法

  1. 系统安装运行条件
1sudo apt update
2sudo apt upgrade
3sudo apt install vim ffmpeg
  1. 新建一个用户和用户组来运行
1# 创建用户组
2groupadd -r navidrome
3
4# 创建用户
5useradd -r -g navidrome -s /sbin/nologin -M -c "Navidrome Daemons" navidrome
  1. 创建navidrome的安装目录和运行目录
1sudo install -d -o navidrome -g navidrome /opt/navidrome
2sudo install -d -o navidrome -g navidrome /var/lib/navidrome
  1. 获取最新安装包

在GitHub的发布页面下载最新版本,将内容解压到可执行的安装目录。

1wget https://github.com/navidrome/navidrome/releases/download/v0.49.3/navidrome_0.49.3_Linux_x86_64.tar.gz -O Navidrome.tar.gz
2sudo tar -xvzf Navidrome.tar.gz -C /opt/navidrome/
3sudo chown -R navidrome:navidrome /opt/navidrome
  1. 创建navidrome的配置文件

查看navidrome给出的配置文件可用选项,自己进行调优

1# 创建配置文件
2vim /var/lib/navidrome/navidrome.toml 
3
4# 编辑写入
5MusicFolder = "<library_path>"
6Port = "31500"

ps:<library_path>修改为音乐文件存放路径,port为远程服务的端口,如果不需要就去除使用默认的4533端口

  1. 创建启动服务选项
1vim /etc/systemd/system/navidrome.service

复制粘贴加入以下内容,要注意的是user和Group的配置,不然会无法启动报错。

 1[Unit]
 2Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
 3After=remote-fs.target network.target
 4AssertPathExists=/var/lib/navidrome
 5
 6[Install]
 7WantedBy=multi-user.target
 8
 9[Service]
10User=navidrome
11Group=navidrome
12Type=simple
13ExecStart=/opt/navidrome/navidrome --configfile "/var/lib/navidrome/navidrome.toml"
14WorkingDirectory=/var/lib/navidrome
15TimeoutStopSec=20
16KillMode=process
17Restart=on-failure
18
19#See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
20DevicePolicy=closed
21NoNewPrivileges=yes
22PrivateTmp=yes
23PrivateUsers=yes
24ProtectControlGroups=yes
25ProtectKernelModules=yes
26ProtectKernelTunables=yes
27RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
28RestrictNamespaces=yes
29RestrictRealtime=yes
30SystemCallFilter=~@clock @debug @module @mount @obsolete @"reboot"#42 @setuid @swap
31ReadWritePaths=/var/lib/navidrome
32
33# You can uncomment the following line if you're not using the jukebox This
34# will prevent navidrome from accessing any real (physical) devices
35#PrivateDevices=yes
36
37# You can change the following line to `strict` instead of `full` if you don't
38# want navidrome to be able to write anything on your filesystem outside of
39# /var/lib/navidrome.
40ProtectSystem=full
41
42# You can comment the following line if you don't have any media in /home/*.
43# This will prevent navidrome from ever reading/writing anything there.
44#ProtectHome=true
  1. 更新并启动navidrome
1# 更新服务列表
2systemctl daemon-reload
3
4# 启动navidrome服务
5systemctl start navidrome.service
6
7# 查看navidrome的服务运行状态
8systemctl status navidrome.service

查看服务状态为Active: active (running)的服务状态,并在防火墙开放当前端口之后

使用IP:你的端口 默认为4533 访问当前服务器,并设置管理员账号密码后,添加自启动服务。

1systemctl enable navidrome.service

支持第三方应用

iOS:play:Sub、 substreamer、 Amperfy和 iSub 安卓:DSub、Subtracks、substreamer、Ultrasonic、Audinaut、音流 网络:Subplayer、 Airsonic Refix、 Aurial、 Jamstash和 Subfire 桌面:Sublime Music (Linux) 和Sonixd (Windows/Linux/macOS) CLI:Jellycli (Windows/Linux) 和STMP (Linux/macOS)

这里安特一下国内开发者的音流APP,暂时支持两个平台subsonicnavidrome