原创文章,转载请注明出处!
前面有篇文章已经有相关的mycloud安装plex的一键包了,不过需要占用500M左右的根空间,安装过程中还需要挂载500mb的/tmp临时目录。
这次,我要说的是,全手动安装plex到nas,实现自定义存放路径+自启动。
1、下载:去官网(www.plex.tv)下载群晖的插件,一个spk为扩展名的包。
例如: PlexMediaServer-0.9.11.16.958-80f1748-arm7.spk //红色部分,请自行更换成你自己的
下载好后,仍到 /share/scjtqs/(我的4T硬盘的存储挂载点)下
2、解包:
cd /share/scjtqs
mkdir plex
mkdir /share/tmp;chmod 777 /share/tmp
mv PlexMediaServer-0.9.11.16.958-80f1748-arm7.spk plex/PlexMediaServer-0.9.11.16.958-80f1748-arm7.tar
cd plex
tar -xvf PlexMediaServer-0.9.11.16.958-80f1748-arm7.tar
解压后会出现几个文件,其中最主要的是我们的 package,tgz
mkdir -p /share/scjtqs/local/plex/Application //这是程序的主目录,请自行更换成你自己的,或者直接用我的,后面的几个代码和脚本中,出现的这个目录,也请更换掉!
tar -xvf package.tgz -C /share/scjtqs/local/plex/Application
3、配置
a)在 vim /etc/default/plexmediaserver
# default script for Plex Media Server # the number of plugins that can run at the same time PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 # ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000 # where the mediaserver should store the transcodes PLEX_MEDIA_SERVER_TMPDIR=/share/tmp # uncomment to set it to something else PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/share/plex/Library/Application\ Support" # the user that PMS should run as, defaults to 'plex' # note that if you change this you might need to move # the Application Support directory to not lose your # media library PLEX_MEDIA_SERVER_USER=plex
b) useradd plex
c) vim /etc/init/plexmediaserver.conf
# plexpms - service job file description "Plex Media Server" author "http://www.plexapp.com/" # When to start the service start on runlevel [2345] # When to stop the service stop on runlevel [016] # Automatically restart process if crashed respawn # Sets nice and ionice level for job nice -5 # What to execute script if [ -r /etc/default/plexmediaserver ]; then . /etc/default/plexmediaserver fi start-stop-daemon --start -c $PLEX_MEDIA_SERVER_USER --exec /usr/sbin/start_pms end script
d) vim /etc/init.d/plexmediaserver
#!/bin/sh ### BEGIN INIT INFO # Provides: plexmediaserver # Required-Start: remote_fssyslog networking # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Plex Media Server # Description: Plex Media Server for Linux, # More information at http://www.plexapp.com # Many thanks to the great PlexApp team for their wonderfull job ! # Author: Cedric Quillevere / [email protected] # Rewamped Christian Svedin / [email protected] # Version: 1.2 ### END INIT INFO # Read configuration variable file if it is present [ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver plex_running=ps ax | grep "\./Plex Media Server" | awk '{ print1 }' | wc -l case "1" in start) if [ "plex_running" -gt 1 ]; then echo "Plex already running..." exit 0 fi echo -n "Starting Plex Media Server: " su -l PLEX_MEDIA_SERVER_USER -c "/usr/sbin/start_pms &" >/dev/null 2>&1 sleep 1 echo "done" ;; stop) if [ "plex_running" -eq 1 ]; then echo "Plex Media Server is not running (no process found)..." exit 0 fi echo -n "Killing Plex Media Server: " # Trying to kill the Plex Media Server itself but also the Plug-ins ps ax | grep "Plex Media Server" | awk '{ print 1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Plug-in" | awk '{ print1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex DLNA Server" | awk '{ print 1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Tuner Service" | awk '{ print1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Media Scanner" | awk '{ print 1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex DLNA Server" | awk '{ print1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Relay" | awk '{ print 1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Transcoder" | awk '{ print1 }' | xargs kill -15 >/dev/null 2>&1 ps ax | grep "Plex Script Host" | awk '{ print 1 }' | xargs kill -15 >/dev/null 2>&1 sleep 1 echo "done" ;; restart) sh0 stop sh 0 start ;; status) if [ "plex_running" -gt 1 ]; then echo "Plex Media Server process running." else echo "It seems that Plex Media Server isn't running (no process found)." fi ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0
chmod 755 /etc/init.d/plexmediaserver
e) vim /usr/sbin/start_pms
#!/bin/sh #change these parameters in /etc/default/plexmediaserver export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 export PLEX_MEDIA_SERVER_HOME=/share/scjtqs/local/plex/Application/ export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000 export PLEX_MEDIA_SERVER_TMPDIR=/share/tmp export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/share/plex/Library/Application\ Support" test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver if [ ! -d "PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ] then mkdir -p "PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" if [ ! ? -eq 0 ] then echo "WARNING COULDN'T CREATEPLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, MAKE SURE I HAVE PERMISSON TO DO THAT!" exit 1 fi fi export LD_LIBRARY_PATH="{PLEX_MEDIA_SERVER_HOME}" export TMPDIR="{PLEX_MEDIA_SERVER_TMPDIR}" echo PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCSPLEX_MEDIA_SERVER_MAX_STACK_SIZE PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR ulimit -sPLEX_MAX_STACK_SIZE (cd /share/scjtqs/local/plex/Application/; ./Plex\ Media\ Server)
chmod +x /usr/sbin/start_pms
然后 service plexmediaserver start
至于自启动。。。我就不多说了,不同的系统不一样的。
我以centos7为例:systemctl enable plexmediaserver
debian例子: update-rc.d plexmediaserver defaults
~~~!到此完结!~~~
音乐好听,听了一晚上