如何在Ubuntu上运行Jellyfin
在安装前,请确保Ubuntu系统已更新至最新版本,以避免依赖冲突:
sudo apt update && sudo apt upgrade -y
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/jellyfin.gpg
echo "deb [arch $(dpkg --print-architecture)] https://repo.jellyfin.org/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/jellyfin.list
sudo apt update
sudo apt install jellyfin -y
sudo apt install snapd -y
sudo snap install jellyfin --classic
curl -s https://repo.jellyfin.org/install-debuntu.sh | sudo bash
安装完成后,Jellyfin会自动注册为系统服务,可通过以下命令管理:
sudo systemctl start jellyfinsudo systemctl enable jellyfinsudo systemctl status jellyfin(显示“active (running)”表示运行正常)8096(如http://192.168.1.100:8096),进入初始设置向导。/home/user/Movies、/home/user/TV Shows),点击“Scan Library”扫描媒体文件。Jellyfin运行时使用的jellyfin用户需对媒体文件夹有读取权限。可通过以下命令授权:
sudo chown -R jellyfin:jellyfin /path/to/media/folder
或创建共享用户组(更灵活):
sudo groupadd media
sudo usermod -aG media jellyfin # 将jellyfin加入media组
sudo usermod -aG media $USER # 将当前用户加入media组
sudo chmod -R 775 /path/to/media/folder
Jellyfin默认不会实时监控文件变动,需手动刷新媒体库:
在Web界面中,进入对应媒体库→点击右上角“…”→选择“Scan Library”或“Refresh Metadata”。
若使用NVIDIA显卡,需安装驱动和NVIDIA Container Toolkit:
sudo ubuntu-drivers autoinstall # 安装NVIDIA驱动
sudo systemctl set-default graphical.target # 确保系统启动到图形界面
sudo apt install nvidia-container-toolkit -y
sudo systemctl restart docker # 若使用Docker版Jellyfin
在Jellyfin Web界面的“Playback”→“Transcoding”中,开启“Hardware Acceleration”选项。
若希望通过域名访问并启用HTTPS,可配置Apache反向代理:
sudo apt install apache2 certbot python3-certbot-apache -y
sudo a2enmod proxy proxy_http ssl proxy_wstunnel
sudo systemctl restart apache2
sudo certbot certonly --agree-tos --email your_email@example.com --no-eff-email --webroot -w /var/www/html -d your_domain.com
/etc/apache2/sites-available/jellyfin.conf,内容如下:<VirtualHost *:80>
ServerName your_domain.com
Redirect permanent / https://your_domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName your_domain.com
DocumentRoot /var/www/html
ProxyPreserveHost On
ProxyPass "/socket" "ws://localhost:8096/socket"
ProxyPassReverse "/socket" "ws://localhost:8096/socket"
ProxyPass "/" "http://localhost:8096/"
ProxyPassReverse "/" "http://localhost:8096/"
SSLCertificateFile /etc/letsencrypt/live/your_domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your_domain.com/privkey.pem
</VirtualHost>
sudo systemctl restart apache2
完成以上步骤后,即可通过https://your_domain.com访问Jellyfin。