首页 文章
取消

Debian部署navidrome

环境:
Debian10.5
caddy2.x
navidrome v0.47.5
所有操作均使用root账户

安装ffmpeg

sudo apt update
sudo apt upgrade
sudo apt install vim ffmpeg

下载navidrome并解压

cd /home
mkdir navidrome
cd navidrome
wget https://github.com/navidrome/navidrome/releases/download/v0.47.5/navidrome_0.47.5_Linux_x86_64.tar.gz
tar -xvzf navidrome_0.47.5_Linux_x86_64.tar.gz

编写配置文件

cd /home/navidrome
vim navidrome.toml
# 写入以下内容
# 音乐文件存放目录
MusicFolder = "/home/music/"
# 以下内容为可选项
# 禁用收藏功能
EnableFavourites = false
# 禁用评分功能
EnableStarRating = false
# 默认主题(一定要双引号)
DefaultTheme = "Spotify-ish"
# 禁用所有外部集成
EnableExternalServices = false
# 禁用文件定时扫描(一定要双引号)
ScanSchedule = "0"

编写守护进程启动文件

注意:本文以root用户启动,故User与Group都不填写

vim /etc/systemd/system/navidrome.service
# 写入以下内容
[Unit]
Description=Navidrome Music Server and Streamer compatible with Subsonic/Airsonic
After=remote-fs.target network.target
AssertPathExists=/home/navidrome

[Install]
WantedBy=multi-user.target

[Service]
#User=<user>
#Group=<group>
Type=simple
ExecStart=/home/navidrome/navidrome --configfile "/home/navidrome/navidrome.toml"
WorkingDirectory=/home/navidrome
TimeoutStopSec=20
KillMode=process
Restart=on-failure

# See https://www.freedesktop.org/software/systemd/man/systemd.exec.html
DevicePolicy=closed
NoNewPrivileges=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
ReadWritePaths=/home/navidrome

# You can uncomment the following line if you're not using the jukebox This
# will prevent navidrome from accessing any real (physical) devices
#PrivateDevices=yes

# You can change the following line to `strict` instead of `full` if you don't
# want navidrome to be able to write anything on your filesystem outside of
# /var/lib/navidrome.
ProtectSystem=full

# You can uncomment the following line if you don't have any media in /home/*.
# This will prevent navidrome from ever reading/writing anything there.
#ProtectHome=true

# You can customize some Navidrome config options by setting environment variables here. Ex:
#Environment=ND_BASEURL="/navidrome"

启动navidrome

sudo systemctl daemon-reload
sudo systemctl start navidrome.service
sudo systemctl status navidrome.service

配置反向代理

vim /etc/caddy/Caddyfile
# 追加以下内容
music.ainoe.one {
     encode gzip
     reverse_proxy 127.0.0.1:4533
}

Tips

统计文件数量的命令

ls -1U [目录路径,统计当前目录时不填写] | wc -l

Reference

navidrome - Github
navidrome docs