如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器

发表 admin at 2025年2月28日
类别
  • 未分类
标签

Jellyfin 是一款免费的开源媒体服务器软件,使用户能够托管和管理个人媒体库、跨设备流式传输内容以及向其他人提供访问权限。它是专有媒体服务器的替代方案,提供广泛的定制和隐私控制。它是 Emby 和 Plex 等专有媒体文件服务器的替代方案。

在本指南中,我们将向您展示如何在 Ubuntu 22.04 上安装 Jellyfin 媒体服务器。您将使用 Apache 作为反向代理安装 Jellyfin,并使用 Letsencrypt 的 SSL/TLS 证书来保护 Jellyfin。

先决条件

在开始之前,请确保您具备以下条件:

  • Ubuntu 22.04 服务器。
  • 具有 sudo 权限的非 root 用户。
  • 域名指向服务器IP地址。

添加 Jellyfin 存储库

首先,运行以下命令将依赖项(例如 software-properties-common、apt-transport-https、ca-certificates、gnupg 和curl)安装到您的 Ubuntu 系统。

sudo apt install software-properties-common apt-transport-https ca-certificates gnupg curl -y

然后,运行以下命令以在 Ubuntu 计算机上启用“universe”存储库。

sudo add-apt-repository universe

现在运行以下命令创建一个新目录 /etc/apt/keyrings 并将 Jellyfin 存储库的 GPG 密钥下载到其中。

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

接下来,运行以下命令将 Jellyfin 存储库添加到您的 Ubuntu 计算机。

cat <<EOF | sudo tee /etc/apt/sources.list.d/jellyfin.sources
Types: deb
URIs: https://repo.jellyfin.org/$( awk -F'=' '/^ID=/{ print $NF }' /etc/os-release )
Suites: $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release )
Components: main
Architectures: $( dpkg --print-architecture )
Signed-By: /etc/apt/keyrings/jellyfin.gpg
EOF

最后,使用以下命令更新并刷新 Ubuntu 系统上的软件包索引。这将检索新的包信息,包括来自 Jellyfin 存储库的信息。

sudo apt update

安装 Jellyfin 服务器

添加 Jellyfin 存储库后,您现在可以在 Ubuntu 服务器上开始 Jellyfin 安装。

执行以下 apt 命令来安装 jellyfin 软件包。出现提示时,输入 Y 进行确认并继续。

sudo apt install jellyfin

安装完成后,运行以下命令来验证 jellyfin 服务并确保该服务正在运行并启用。

sudo systemctl is-enabled jellyfin
sudo systemctl status jellyfin

在以下输出中,您可以看到 Jellyfin 正在运行并启用。

您还可以使用下面的 ss 命令验证 Jelly 的端口。

ss -tulpn | grep jellyfin

您可以看到不同的端口 8096/tcp(用于 HTTP 流量)、8920/tcp(用于 HTTPS 流量)、1900/udp 和 7359/udp(用于服务自动发现)。

生成 SSL/TLS 证书

在本指南中,您将使用 SSL/TLS 证书和 Apache 反向代理来保护 Jeallyfin 安装的安全。现在,您将通过 Certbot 和 LetsEncrypt 生成 SSL/TLS 证书。

PS:如果您在本地环境中,也可以使用自签名证书。但对于外部部署,请确保您的域名已准备好并指向您的 Ubuntu IP 地址。

运行以下命令将 Certbot 安装到您的 Ubuntu 系统。输入 Y 并按 ENTER 继续。

sudo apt install certbot

现在运行以下命令创建一个新目录/var/www/html。

mkdir -p /var/www/html

最后,运行下面的 certbot 命令为您的 Jellyfin 域名生成 SSL/TLS 证书。请务必使用您的详细信息更改电子邮件地址和域名。

sudo certbot certonly --agree-tos --email [email  --no-eff-email --webroot -w /var/www/html -d media.hwdomain.io

所有过程完成后,您的 SSL/TLS 证书将在 /etc/letsencrypt/live/domain.com 目录中可用。

将 Apache 配置为反向代理

在本部分中,您将安装并配置 Apache Web 服务器作为 Jellyfin 的反向代理。让我们开始吧。

首先,运行以下命令将 Apache Web 服务器安装到您的系统中。

sudo apt install apache2 -y

安装完成后,运行下面的 a2enmod 命令以在安装中启用所需的 Apache 模块。

sudo a2enmod proxy proxy_http ssl proxy_wstunnel remoteip http2 headers

现在运行以下 nano 编辑器命令来创建新的 Apache 虚拟主机文件 /etc/apache2/sites-available/jellyfin.conf。

sudo nano /etc/apache2/sites-available/jellyfin.conf

插入以下配置来为 Jeallyfin 设置反向代理。请务必使用您的详细信息更改 SSL 证书的域名和路径。

<VirtualHost *:80>
 ServerName media.hwdomain.io
 # Comment to prevent HTTP to HTTPS redirect
 Redirect permanent / https://media.hwdomain.io/
 ErrorLog /var/log/apache2/media.hwdomain.io-error.log
 CustomLog /var/log/apache2/media.hwdomain.io-access.log combined
</VirtualHost>
# If you are not using an SSL certificate, replace the 'redirect'
# line above with all lines below starting with 'Proxy'
<IfModule mod_ssl.c>
<VirtualHost *:443>
 ServerName media.hwdomain.io
 # This folder exists just for certbot(You may have to create it, chown and chmod it to give apache permission to read it)
 DocumentRoot /var/www/html/jellyfin/public_html
 ProxyPreserveHost On
 # Letsencrypt's certbot will place a file in this folder when updating/verifying certs
 # This line will tell Apache to not to use the proxy for this folder.
 ProxyPass "/.well-known/" "!"
 # Tell Jellyfin to forward that requests came from TLS connections
 RequestHeader set X-Forwarded-Proto "https"
 RequestHeader set X-Forwarded-Port "443"
 ProxyPass "/socket" "ws://192.168.5.30:8096/socket"
 ProxyPassReverse "/socket" "ws://192.168.5.30:8096/socket"
 ProxyPass "/" "http://192.168.5.30:8096/"
 ProxyPassReverse "/" "http://192.168.5.30:8096/"
 SSLEngine on
 SSLCertificateFile /etc/letsencrypt/live/media.hwdomain.io/fullchain.pem
 SSLCertificateKeyFile /etc/letsencrypt/live/media.hwdomain.io/privkey.pem
 Protocols h2 http/1.1
 # Enable only strong encryption ciphers and prefer versions with Forward Secrecy
 SSLCipherSuite HIGH:RC4-SHA:AES128-SHA:!aNULL:!MD5
 SSLHonorCipherOrder on
 # Disable insecure SSL and TLS versions
 SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
 ErrorLog /var/log/apache2/media.hwdomain.io-error.log
 CustomLog /var/log/apache2/media.hwdomain.io-access.log combined
</VirtualHost>
</IfModule>

完成后保存并关闭文件。

接下来,运行以下命令启用虚拟主机文件 jellyfin.conf。然后,验证您的 Apache 配置以确保语法正确。

sudo a2ensite jellyfin.conf
sudo apachectl configtest

如果一切顺利,您应该会看到诸如“语法正常”之类的输出。

现在运行 systemctl 命令以重新启动 Apache 服务并应用更改。

sudo systemctl restart apache2

重新启动后,验证 Apache 服务以确保该服务正在运行并启用。

sudo systemctl is-enabled apache2
sudo systemctl status apache2

如果一切顺利,您应该会看到 Apache 已启用并在您的 Ubuntu 计算机上运行。

配置UFW

安装 Jellyfin 后,让我们配置 UFW 以保护您的安装。

首先,运行以下命令打开 SSH、HTTP 和 HTTPS 端口。

sudo ufw allow OpenSSH
sudo ufw allow 'Apache Full'

现在使用以下命令打开端口 1900/udp 和 7359/udp 进行自动发现。

sudo ufw allow 1900/udp
sudo ufw allow 7359/udp

接下来,运行以下命令来启动并启用 UFW。键入 Y 进行确认。

sudo ufw enable

最后,使用以下命令验证 UFW 上的端口和服务列表。

sudo ufw status

您将看到 OpenSSH 和“Apache Full”配置文件已启用,并且端口 1900/udp 和 7359/udp 也已添加到 UFW。

安装 Jellyfin 媒体服务器

至此,所有依赖项都已配置完毕。您现在可以从 Web 浏览器访问 Jellyfin 安装。

使用 Web 浏览器访问 Jellyfin 服务器的域名(即:https://media.hwdomain.io/)。您将看到来自 Jellyfin 的欢迎消息。

单击下一步继续。

现在在 Jellyfin 上创建您的第一个用户,然后单击下一步。

现在系统会要求您为 Jellyfin 设置媒体库,单击下一步跳过它。配置完成后,您可以稍后进行配置。

选择您首选的元数据语言,然后再次单击下一步。

对于“远程访问”部分,选中“允许远程连接”和“自动端口映射”复选框。然后,单击下一步进行确认。

最后,单击“完成”即可完成 Jellyfin 安装。

您将被重定向到 Jellyfin 登录页面。输入您的用户名和密码,然后点击登录。

现在您将看到 Jellyfin 仪表板,如下所示:

如果单击“管理”菜单,您将看到有关 Jellyfin 服务器的详细信息。在此示例中,您可以看到 Ubuntu 系统上安装了 Jellyfin xxx。

结论

恭喜!您现在已经在 Ubuntu 22.04 服务器上成功安装了 Jellyfin 媒体服务器。您还使用 Apache 作为反向代理和 Letsencrypt 的 SSL/TLS 来保护 Jellyfin 的安全。从现在开始,您可以添加媒体文件库并将您的库收藏存储在 Jellyfin 上。

©2015-2025 Norria support@alaica.com