自建服务器搭建网盘,自建云盘系列——Plex (建立你的私人在线片库)

一.介绍

想了想,感觉Plex放到这个系列里还是比较合适的,毕竟专用于存储影片的也算是云盘嘛,而且前面介绍了一堆下载和存储的教程,现在放个这个出来也是挺好的,之后我打算把之前几个在V2上收藏的追番的啥的工具也介绍一下。

如果要想知道什么是Plex,简单的来说,存储+索引+转码+在线播放 这几个标签就能概括Plex的主要功能,在LinusTechTips的某集中还曾经介绍过这个,能够在你自己的设备(NAS或者服务器)上搭建属于你自己的媒体库。全称Plex Media Server,它不仅仅是简单的存储,它还能分析影片的信息从而从IMDB等数据库补全影片介绍等信息,并且进行索引以方便搜索,要知道影片的格式有很多种,很多情况下播放设备无法兼容,所以它还能实时转码,播放渠道从网页到全平台的客户端应有尽有。(当然,号称Media肯定不止能存片,还能存图存歌等等)

二.安装

全部安装方式请参考官网,我这边只给出部分——>传送门

#64位

yum install https://downloads.plex.tv/plex-media-server/1.9.4.4325-1bf240a65/plexmediaserver-1.9.4.4325-1bf240a65.x86_64.rpm

#32位

yum install https://downloads.plex.tv/plex-media-server/1.9.4.4325-1bf240a65/plexmediaserver-1.9.4.4325-1bf240a65.i386.rpm

1

2

3

4

#64位

yuminstall https://downloads.plex.tv/plex-media-server/1.9.4.4325-1bf240a65/plexmediaserver-1.9.4.4325-1bf240a65.x86_64.rpm

#32位

yuminstall https://downloads.plex.tv/plex-media-server/1.9.4.4325-1bf240a65/plexmediaserver-1.9.4.4325-1bf240a65.i386.rpm

启动参数比较多,请参考官方GitHub的说明——>传送门

如果嫌麻烦也可以用第三方做的Docker镜像,去DockerHub搜搜应该有不少

三.配置

这部分的话和其他的Plex教程不太一样,因为Plex默认禁止远程访问,所以大部分教程都是让开一个SSH转发来实现第一次配置的,我不太喜欢这种方式,于是翻来翻去,终于找到另外一种方法,就是直接通过命令行修改配置文件将设备直接链接到你的Plex账户,从而完成配置。(这个方法其实在Plex的Docker里用得比较多)

/etc/init.d/plexmediaserver start

/etc/init.d/plexmediaserver stop

yum install xmlstarlet -y

PLEX_TOKEN=$(curl -qu "Plex用户名":"Plex密码" 'https://plex.tv/users/sign_in.xml' \

-X POST -H 'X-Plex-Device-Name: PlexMediaServer' \

-H 'X-Plex-Provides: server' \

-H 'X-Plex-Version: 0.9' \

-H 'X-Plex-Platform-Version: 0.9' \

-H 'X-Plex-Platform: xcid' \

-H 'X-Plex-Product: Plex Media Server'\

-H 'X-Plex-Device: Linux'\

-H 'X-Plex-Client-Identifier: XXXX' --compressed | sed -n 's/.*\(.*\).*/\1/p')

xmlstarlet ed --inplace --insert "Preferences" --type attr -n "AcceptedEULA" -v "1" "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarlet ed --inplace --insert "Preferences" --type attr -n "FirstRun" -v "0" "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarlet ed --inplace --insert "Preferences" --type attr -n "PlexOnlineUsername" -v "Plex用户名" "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarlet ed --inplace --insert "Preferences" --type attr -n "PublishServerOnPlexOnlineKey" -v "1" "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarlet ed --inplace --insert "Preferences" --type attr -n "PlexOnlineToken" -v "${PLEX_TOKEN}" "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

/etc/init.d/plexmediaserver restart

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

/etc/init.d/plexmediaserverstart

/etc/init.d/plexmediaserverstop

yuminstallxmlstarlet-y

PLEX_TOKEN=$(curl-qu"Plex用户名":"Plex密码"'https://plex.tv/users/sign_in.xml'\

-XPOST-H'X-Plex-Device-Name: PlexMediaServer'\

-H'X-Plex-Provides: server'\

-H'X-Plex-Version: 0.9'\

-H'X-Plex-Platform-Version: 0.9'\

-H'X-Plex-Platform: xcid'\

-H'X-Plex-Product: Plex Media Server'\

-H'X-Plex-Device: Linux'\

-H'X-Plex-Client-Identifier: XXXX'--compressed|sed-n's/.*\(.*\).*/\1/p')

xmlstarleted--inplace--insert"Preferences"--typeattr-n"AcceptedEULA"-v"1""/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarleted--inplace--insert"Preferences"--typeattr-n"FirstRun"-v"0""/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarleted--inplace--insert"Preferences"--typeattr-n"PlexOnlineUsername"-v"Plex用户名""/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarleted--inplace--insert"Preferences"--typeattr-n"PublishServerOnPlexOnlineKey"-v"1""/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

xmlstarleted--inplace--insert"Preferences"--typeattr-n"PlexOnlineToken"-v"${PLEX_TOKEN}""/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

/etc/init.d/plexmediaserverrestart

请确认Preferences.xml文件的位置,当然,这个必要条件是预先运行过一次plex,不然这个是不存在的,所以一开始要先start然后stop,当然,别全复制了然后直接粘贴执行了,请先把用户名密码替换成你自己的,Plex用邮箱注册后可以在账户信息里添加用户名。

这边执行完你就可以访问http://IP:32400/ 然后会自动跳转,如果没问题你会看到左侧出现你的服务器了,如果不正常请确认下token是否正确

四.插件

Plex有很多非官方插件,能够提供各种Channel或者提供补全影片Meta信息的Agent,安装方法都比较简单,下载,解压,改名然后放到插件目录就行,下面举个栗子方便理解(各系统的插件目录可能位置不同)

cd "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins"

wget https://github.com/plexinc-agents/Sub-Zero.bundle/archive/master.zip

unzip master.zip

rm -f master.zip

mv Sub-Zero.bundle-master Sub-Zero.bundle

chown -R plex:plex Sub-Zero.bundle

/etc/init.d/plexmediaserver restart

1

2

3

4

5

6

7

cd"/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins"

wgethttps://github.com/plexinc-agents/Sub-Zero.bundle/archive/master.zip

unzipmaster.zip

rm-fmaster.zip

mvSub-Zero.bundle-masterSub-Zero.bundle

chown-Rplex:plexSub-Zero.bundle

/etc/init.d/plexmediaserverrestart

其他的请自己在GitHub上以及Plex论坛或者Reddit上搜索

五.美化

尽管Plex默认的界面已经挺好了,但是你还有其他的选择,那就是PlexPy,对比Plex自带的来说,这个方便的是不用折腾上面的配置部分,可以直接由PlexPy来将你的Plex服务器链接到你的账户上去,虽然在PlexPy中播放视频还是会跳转一下,不过还行啦,缺点的话貌似是没有中文来着,我之后研究下看看能不能适配中文,如果没有分离语言文件就没办法了。

安装方法比较简单,官方Wiki——>传送门

确保你安装了git

cd /opt

git clone https://github.com/JonnyWong16/plexpy.git

wget -O /etc/init.d/plexpy https://raw.githubusercontent.com/JonnyWong16/plexpy/master/init-scripts/init.fedora.centos.service

chmod +x /etc/init.d/plexpy

chkconfig --add plexpy

service plexpy start

1

2

3

4

5

6

cd/opt

gitclonehttps://github.com/JonnyWong16/plexpy.git

wget-O/etc/init.d/plexpy https://raw.githubusercontent.com/JonnyWong16/plexpy/master/init-scripts/init.fedora.centos.service

chmod+x /etc/init.d/plexpy

chkconfig--addplexpy

serviceplexpystart

其他系统的参照官方文档——>传送门

那个init-scripts目录里有好多系统的,所以如果文档里没说到的可以去看看有没有,然后你就可以访问http://IP:8181/ 会有一个配置流程,走一遍就OK

PS.想知道为啥这篇文章没图吗……因为存了点那啥片,然后一堆缩略图比较蛋疼,所以就不截图了,最后放一张正常的,这是Plex的,PlexPy的自己看GitHub有图

自建服务器搭建网盘,自建云盘系列——Plex (建立你的私人在线片库)_第1张图片

你可能感兴趣的:(自建服务器搭建网盘)