温馨提示×

如何在Ubuntu上安装Jellyfin

小樊
41
2025-03-23 01:40:28
栏目: 智能运维
Ubuntu服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Ubuntu上安装Jellyfin可以通过以下步骤完成:

安装Jellyfin

  1. 更新系统并安装必要的包
sudo apt update
sudo apt install apt-transport-https ca-certificates gnupg curl
  1. 创建keyrings目录并添加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
  1. 添加Jellyfin仓库
cat <<EOF | sudo tee /etc/apt/sources.list.d/jellyfin.sources
deb [arch=$(dpkg --print-architecture)] https://repo.jellyfin.org/debian $(lsb_release -c -s) main
EOF
  1. 更新包列表
sudo apt update
  1. 安装Jellyfin
sudo apt install jellyfin -y
  1. 验证Jellyfin服务
sudo systemctl is-enabled jellyfin
sudo systemctl status jellyfin
  1. 管理Jellyfin服务(如启动、停止、重启Jellyfin服务):
sudo systemctl start jellyfin
sudo systemctl stop jellyfin
sudo systemctl restart jellyfin
  1. 配置防火墙(如安装UFW并允许必要的服务):
sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw allow "WWW Full"
sudo ufw status
  1. 安装Apache和Certbot用于SSL配置
sudo apt install apache2 certbot python3-certbot-apache -y
sudo systemctl is-enabled apache2
sudo systemctl status apache2
sudo a2enmod proxy proxy_http ssl proxy_wstunnel remoteip http2 headers
sudo systemctl restart apache2
  1. 设置Apache作为反向代理
  • 创建Jellyfin的web根目录并设置权限:
sudo mkdir -p /var/www/html/jellyfin/public_html
sudo chown -R www-data:www-data /var/www/html/jellyfin/public_html
  • 使用Certbot为你的域名获取SSL证书:
sudo certbot certonly --agree-tos --email your_email@gmail.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
    # Comment to prevent HTTP to HTTPS redirect
    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/"
    IfModule mod_ssl.c
        SSLEngine on
        SSLCertificateFile /path/to/your_domain.crt
        SSLCertificateKeyFile /path/to/your_domain.key
    </VirtualHost>
  1. 重启Apache
sudo systemctl restart apache2

以上步骤涵盖了从更新系统包到配置SSL证书的完整安装流程,确保了Jellyfin媒体服务器的安全性和稳定性。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:如何在ubuntu上安装jellyfin插件

0