I use Plex Media Server running on a storage-focused VPS to manage and organize nearly every piece of digital content in my life (Audible audiobooks, camera uploads, podcasts, music, etc.)
The VPS runs Debian 8, and doesn't include the ability to perform tasks as the root user (using
sudo), which makes it difficult to run any third-party services from the machine itself. Initially I had found this tutorial on Tumblr, but recent updates to Plex made the tutorial incomplete.
First let's create a few directories in our non-root user's home folder which we can use to store the various parts of Plex's application infrastructure.
zac@server:~$ mkdir plex zac@server:~$ mkdir plex-support zac@server:~$ cd plex/
plex folder will hold all of Plex's application files, while the
plex-support folder will hold all of Plex's configurations and databases. This allows us to quickly update Plex in the future and not lose any of our configurations, plugins, or our database of media.
Next, download the latest Ubuntu release of Plex Media Server and download it into the newly created
plex folder. The link should look something like: https://downloads.plex.tv/plex-media-server/220.127.116.1122-4955e31cf/plexmediaserver_18.104.22.16822-4955e31cf_amd64.deb
zac@server:~/plex$ wget https://downloads.plex.tv/plex-media-server/22.214.171.12422-4955e31cf/plexmediaserver_126.96.36.19922-4955e31cf_amd64.deb
You'll now have the
plexmediaserver_*.deb file in your
Now, we'll extract the package's contents.
zac@server:~/plex$ ar x plexmediaserver_188.8.131.5222-4955e31cf_amd64.deb
Once complete, our
~/plex folder will contain
plexmediaserver_*.deb. We can delete everything except for
zac@server:~/plex$ rm -f control.tar.gz debian-binary _gpgkey plexmediaserver*
Next, let's extract data.tar.gz and then remove it.
zac@server:~/plex$ tar xzvf data.tar.gz zac@server:~/plex$ rm -f data.tar.gz
~/plex folder should now contain 3 folders,
At this point, we're ready to start the Plex Media Server services. Usually this is done by using Plex's
start.sh file, but since we're running Plex from outside it's traditional directory structure this can be problematic. We could also modify the
start.sh file, but then we'd need to re-modify that file for each time we update Plex.
To start Plex we'll execute it's main process while also overriding some of it's default execution flags to point to our newly created/extracted directories.
zac@server:~/plex$ cd usr/lib/plexmediaserver/
Now that we're in Plex's core directory, we can execute it's main binary with some configuration options.
zac@server:~/plex/usr/lib/plexmediaserver$ LD_LIBRARY_PATH=~/plex/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_HOME=~/plex/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=~/plex-support ./Plex\ Media\ Server &
You can read this for more explanation as to Plex's configuration options, but essentially:
LD_LIBRARY_PATH: Tells Plex where to find it's runtime libraries/helpers for some of Plex's built-in functionality.
PLEX_MEDIA_SERVER_HOME: Tells Plex where to find itself. We override this since we've installed Plex outside it's normal directory structure.
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS: Tells Plex the number of plugins that it can run at the same time (6 is the default).
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR: Tells Plex where to install it's configurations, user databases, and other user-specific files. This is where the main Plex database will be stored. If this folder is removed you'll have a fresh installation of Plex (no libraries, configurations).
Now that Plex is running, let's disown the process from our shell's control. Since we don't intend to keep an SSH session running for the duration of the time we want to use Plex, we'll use
disown to relinquish the process we started in the backgound (notice the
& at the end of our command above).
Now that it's all set up and running, we'll need to configure it.
When Plex first starts, it's listening only on
localhost, and requires you to login to finish the configuration. We can get around this by creating an SSH tunnel with the remote port forwarded to one of our local ports.
zac@local:~$ ssh zac@server -L 8888:localhost:32400
This will open an SSH connection to the remote Plex server that we've just configured (
zac@server), and map it's local port
32400 (Plex's default port) to our local port
Note: If successful, the SSH connection won't appear to be active. You won't be given an interactive terminal like we were using during the install steps.
If we open our browser to http://localhost:8888 we'll be directed to sign in and configure the Plex server. Once you've successfully configured the Plex server, you can close the SSH connection and login to your newly configured Plex server here: https://plex.tv/web.
To upgrade your installation of Plex Media Server, follow the Installation steps from above again while being sure not to modify or delete the
~/plex-support folder (or whatever you created as an equivalent).
Here's what an upgrade looks like:
zac@server:~$ rm -rf plex/ zac@server:~$ mkdir plex/ zac@server:~$ cd plex/ zac@server:~/plex$ wget https://downloads.plex.tv/plex-media-server/184.108.40.20622-4955e31cf/plexmediaserver_220.127.116.1122-4955e31cf_amd64.deb zac@server:~/plex$ ar x plexmediaserver_18.104.22.16822-4955e31cf_amd64.deb zac@serverL~/plex$ tar xzvf data.tar.gz zac@server:~/plex$ rm -f control.tar.gz debian-binary data.tar.gz _gpgkey plexmediaserver* zac@server:~/plex$ cd usr/lib/plexmediaserver/ zac@server:~/plex/usr/lib/plexmediaserver$ LD_LIBRARY_PATH=~/plex/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_HOME=~/plex/usr/lib/plexmediaserver PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=~/plex-support ./Plex\ Media\ Server & zac@server:~/plex/usr/lib/plexmediaserver$ disown zac@server:~/plex/usr/lib/plexmediaserver$ exit
- What does ampersand mean at the end of a shell script line? https://unix.stackexchange.com/a/86249
- Difference between nohup, disown and & https://unix.stackexchange.com/a/148698
- SSH Tunnel - Local and Remote Port Forwarding Explained With Examples http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
- Plex - Linux: User and Storage configuration https://support.plex.tv/hc/en-us/articles/200273978-Linux-User-and-Storage-configuration
- Install Plex on your Seedbox(server) without Root!(sudo) http://techngeek.tumblr.com/post/66688615146/install-plex-on-your-seedboxserver-without