在Ubuntu上安装和配置Jellyfin媒体服务器的步骤如下:
更新系统:
sudo apt update
sudo apt upgrade -y
安装必要的包:
sudo apt install apt-transport-https ca-certificates gnupg curl -y
创建密钥环目录并添加Jellyfin GPG密钥:
mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.jellyfin.org/jellyfin_team.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/jellyfin.gpg
添加Jellyfin仓库:
cat <<EOF | sudo tee /etc/apt/sources.list.d/jellyfin.sources
Types: deb
URIs: https://repo.jellyfin.org/
Suites: $(lsb_release -cs)
Components: main
Architectures: amd64
Signed-By: /etc/apt/keyrings/jellyfin.gpg
EOF
更新包列表:
sudo apt update
安装Jellyfin:
sudo apt install jellyfin -y
验证Jellyfin服务:
sudo systemctl is-enabled jellyfin
sudo systemctl status jellyfin
管理Jellyfin服务:
sudo systemctl start jellyfin
sudo systemctl stop jellyfin
sudo systemctl restart jellyfin
配置防火墙(可选):
sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw allow "WWW Full"
sudo ufw status
安装Apache和Certbot(用于SSL配置,可选):
sudo apt install apache2 certbot python3-certbot-apache -y
sudo systemctl is-enabled apache2
sudo systemctl restart apache2
设置Apache作为反向代理:
sudo mkdir -p /var/www/html/jellyfin/public_html
sudo chown -R www-data:www-data /var/www/html/jellyfin/public_html
sudo certbot certonly --agree-tos --email your_email@example.com --no-eff-email --webroot -w /var/www/html -d your_domain
配置Apache虚拟主机:
sudo nano /etc/apache2/sites-available/jellyfin.conf
插入以下内容,根据需要更改域名、SSL证书路径和服务器IP地址:
<VirtualHost *:80>
ServerName your_domain
Redirect permanent / https://your_domain/
ErrorLog ${APACHE_LOG_DIR}/your_domain-error.log
CustomLog ${APACHE_LOG_DIR}/your_domain-access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName your_domain
DocumentRoot /var/www/html/jellyfin/public_html
ProxyPreserveHost On
ProxyPass "/.well-known/" "!"
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
ProxyPass "/socket" "ws://0.0.0.0:8096/socket"
ProxyPassReverse "/socket" "ws://0.0.0.0:8096/socket"
ProxyPass "/" "http://0.0.0.0:8096/"
ProxyPassReverse "/" "http://0.0.0.0:8096/"
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/your_domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your_domain/privkey.pem
</VirtualHost>
重启Apache:
sudo systemctl restart apache2
添加媒体库:
完成以上步骤后,你就成功在Ubuntu上安装并配置了Jellyfin媒体服务器。