How to install Plex Media Server on Ubuntu Server Headless

[vc_tta_tabs active_section=”1″ pagination_style=”outline-square”][vc_tta_section title=”Summary” tab_id=”1483657727692-588765df-8139e50c-cffe9549-9db4″][vc_custom_heading text=”Problem / Outcome Summary”]
  • This howto will enable you to install the Plex Media Server on Ubuntu Server
  • For how to install Plex Media Server on another operating system, please click your Platform: Windows
  • Please see the ‘Summary Overview’ tab below for a high level view of the objectives this ‘howto’ will achieve.

Why might I want to do this?

  • To run Plex on a machine that is ‘headless’ and doesn’t have the overhead of running a full Graphical User Environment (GUI)
  • To run Plex as a service, in the background, automatically starting at boot time
  • To move Plex from your NAS which may not have enough CPU to cope with demand
  • Because Plex is on a machine that’s get’s disconnected from the network and you want to change to a permanently connected system
  • Because you know that running it on Ubuntu Linux headless is more powerful running it on Windows, MacOSX, Ubuntu (GUI) or a NAS

See also

[/vc_tta_section][vc_tta_section title=”Foreword” tab_id=”1483656936153-fec58c10-e606e50c-cffe9549-9db4″][vc_custom_heading text=”Foreword”]

To be clear, what is Plex and why does running it on Ubuntu Server Headless make any difference?

Plex is a fantastic media centre based on the software now known as Kodi, and formerly known as XBMC.  The main difference between the two, is that Plex runs a true client / server setup, which means your IT knowledge doesn’t have to be at expert level to get a multi user, multi client setup running.  Plex runs both a free and a subscription model, with the most significant differences being the subscription model get’s bug fixes and updates quicker and more recently a few enhanced features.  The most noteable of those features in my opinion is the inclusion of a Spotify like music organisation and listening experience.

At some point in your Plex journey, you may find yourself listening to your music at work, or watching home video’s on multiple computers.  When this happens, you’re likely to need an always on system, a more powerful system or perhaps getting a bit more power out of your existing system by re-purposing it with Linux.

The latter case is the intent of this article, which has been chosen to run on Ubuntu Linux (Server Edition), because Ubuntu is supported by Plex officially and Ubuntu is the only true headless option out of the supported options (excluding the usually much lower powered NAS options).

On the face of it, an Ubuntu Server (or any other text based Server) is cold boring and mysterious, the domain of a true geek, however that is exactly the power of a text based system – when you realise it is running in the corner with the sole task of serving you and your Plex setup (because there is no complicated GUI, no services running you don’t need, and valuable CPU cycles are not being used up by antivirus or any other non-essential tool) it is quite an eye opening experience.  Because Plex can be quite CPU intensive, this method works well.

What things use up the CPU?

Basically it comes down to this:

  1. Plex runs in two modes for video, one mode is a direct non CPU intensive playback mode (i.e. no transcoding) which comprises of:
    1. Playback devices that have Plex installed and appropriate codecs attached
    2. Devices that are non-plex but have appropriate codecs attached
  2. The other mode is a ‘Transcode’ mode which comprises of:
    1. Devices that do not understand all video formats such as Apple TV
    2. Devices that are constrained by bandwidth (such as when you connect to your home setup over the internet)

Simply put, the transcoding feature of Plex uses the CPU to re-encode your video or music into a format supported by the device you’re playing it on, or to an appropriate quality level to match the available bandwidth you have.

[/vc_tta_section][vc_tta_section title=”Pre-Requisites” tab_id=”1483656936239-1facad3b-9216e50c-cffe9549-9db4″][vc_custom_heading text=”Pre-Requisites”]

Software Dependencies

  • Ubuntu Linux
  • Plex Media Server

Hardware Dependencies

  • The hardware your Ubuntu Linux runs on
  • An internet Modem / Router / Switch to connect your Plex Media Server and client through

Tools Required

  • SSH Access
  • A recent Web Browser

Other Dependencies

  • A working internet connection
[/vc_tta_section][vc_tta_section title=”Summary Steps” tab_id=”1483657008528-9fc62da7-5742e50c-cffe9549-9db4″][vc_custom_heading text=”High Level Summary Steps”]

The below lists the high level summary of steps we’re about to take during this howto.

  • Install Ubuntu Linux on your desired hardware (currently out of scope of this article)
  • Install the latest Plex Media Server onto Ubuntu Linux
  • Configure Plex Media Server
[/vc_tta_section][vc_tta_section title=”Implementation” tab_id=”1483657023013-0e8f9bfb-cd0fe50c-cffe9549-9db4″][vc_custom_heading text=”Implementation”]

Steps to Install Plex Media Server on Ubuntu Linux

Download the latest Plex Media Server from plex.tv

This guide uses the official Plex Media Server package, rather than an unofficial third party repository, this way you can be sure of the quality and authenticity of the software.

When you first start using a headless (text only) type of system, it suddenly becomes apparent that you’re going to have to learn some new things.  Specifically, how to use the command line and how to get by without a web browser.  However, this is actually easier than it sounds and although all the specifics will not be covered here, it’s fairly easy to follow the steps below with little experience.

The first challenge for this installation is figuring out how you get the Plex Media Server onto the headless (no GUI) Ubuntu Server without a web browser.  While there are a few ways of doing this, including using a USB stick, using a text mode browser such as Lynx and mounting a network drive, by far the easiest currently is copying the link from another computers browser and into a terminal session via SSH.  If you’re in Windows, you’re going to need PuTTy, however Mac has ssh included.

The first step is: In a normal PC web browser, go to https://plex.tv/downloads and click on the orange ‘download button in the sign up and download section.  Ensure that the Operating system (which auto detects the one your web browser is on) is set to Linux.  Next click the download button under that and choose Ubuntu64bit or 32bit as appropriate.  On the new web site it is no longer possible to just right click the icon and copy the link.  Now, you must start an actual download to your main computer before this link can be copied.  Once the download has begun, in firefox or Safari you can ‘right click the download in the browser and choose ‘copy link’.  For Chrome, you need to click the ‘show all’ icon at the bottom right, then in the screen that comes up, right click that and choose copy link address.

Also, don’t forget to do this under the Plex Pass menu (if you have one) rather than the Public Downloads menu.

The second step is to copy into your headless machine via an SSH session.

SSH to your new ubuntu server

$ ssh username@192.168.1.x

In the window that comes up, type ‘wget’ and then press CTRL-V or right click and paste the link you just copied.  Then press enter.  This should downlaod the Plex package from plex.tv onto your new Linux box.

The syntax will look similar to: wget https://downloads.plex.tv/plex-media-server/0.9.12.6.1347-54c2e56/plexmediaserver_0.9.12.6.1347-54c2xx_amd64.deb

Install Plex

sudo dpkg -i plexmediaserver_0.9.12.6.1347-54c2xx_amd64.deb

You will then be prompted for your password
[sudo] password for username_here:

Then the package will be installed and you should see similar to the below:
Selecting previously unselected package plexmediaserver.
(Reading database … 55709 files and directories currently installed.)
Preparing to unpack plexmediaserver_0.9.12.6.1347-54c2e56_amd64.deb …
Unpacking plexmediaserver (0.9.12.6.1347-54c2e56) …
Setting up plexmediaserver (0.9.12.6.1347-54c2e56) …
OK
plexmediaserver start/running, process 1208
Processing triggers for ureadahead (0.100.0-16) …
ureadahead will be reprofiled on next reboot
Processing triggers for mime-support (3.54ubuntu1.1) …

If dpkg reports an error about dependency problems, run sudo apt-get install -f to download the missing dependencies and configure everything, but this is likely not necessary for most installations.

Configure Plex – Ensure your media is available.

You need to ensure you have the music, home video’s etc in a location Ubuntu Linux can see them, this could be on a disk attached directly to Linux or on a network device.  In my case, I use a NAS.

In linux, it’s generally better to use NFS because NFS uses a lot less CPU to run and is quite simple to set up, however SMB / CIFS currently works better on QNAP NAS (which I have) due to a bug.

On your Ubuntu linux Plex box ensure you have your NAS mount points mounted in the mnt directory, so you can connect through them from Plex.

Firstly make the directories (or ‘folders’) where the mount will connect to:

mkdir /mnt/Video

mkdir / mnt/Audio etc

Make sure you install the required network connection software for your scenario:

For NFS:

sudo apt-get install rpcbind nfs-common (enter your password and watch the installation run)
For samba
For SMB/CIFS (What Windows uses)
sudo apt-get install cifs-utils
Make a persistent mount to your network shares on Linux by editing the /etc/fstab file
vi /etc/fstab (if you don't like vi, try nano
The format is as follows:
servername:dir /mntpoint protocol access, options
In the fstab file, you should end up with lines similar to below for each network mount:
//192.168.1.15/Video /mnt/Video  cifs  guest,uid=1000,iocharset=utf8  0  0
//192.168.1.15/Audio /mnt/Audio  cifs  guest,uid=1000,iocharset=utf8  0  0

In my case, I was migrating my database from OSX and had to copy it from Mac OSX to Linux.

To do this, ensure you disable the ‘Empty Trash Automatically After every scan’ check box in Plex Server / Library page on the TARGET Plex server, (this is because it will for a time have no library and it may decide to delete stuff you want to keep).

Quit/stop your Plex Media Server in both the original location and the target location (no Plex Media Server should be running while it’s database is being moved or created)

On Ubuntu

service plexmediaserver stop

service plexmediaserver status (to check it has been stopped – it should say stop/waiting if stopped)

Copy your DATABASE files to the location of the new plex media

The locations where you can copy from and to are listed below:

Windows: %LOCALAPPDATA%Plex Media Server
OSX: ~/Library/Application Support/Plex Media Server/
Linux: $PLEX_HOME/Library/Application Support/Plex Media Server/ (on ubuntu Library is located in /var/lib)
QNAP NAS: /share/MD0_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/
ReadyNAS NAS ROS4: /c/.plex/Library/
ReadyNAS NAS ROS6: /apps/plexmediaserver/MediaLibrary/Plex Media Server/
Synology NAS: /Volume1/Plex/Library/Application Support/Plex Media Server/

In my case I’m moving from OSX to Ubuntu (mainly because even with the OSX automount options explained here, OSX still can’t give a reliable persistent mounting system due to bugs).

On the Mac: rsync -avh –progress ~/Library/Application Support/Plex Media Server username@192.168.43.20:/home/username/

rsync -av  ~/Library/Preferences/com.plexapp.plexmediaserver.plist username@192.168.43.20:/home/username/

On Linux rsync -avh –progress /home/username/Plex Media Server/ /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/ –whole-file –delete-after

rsync com.plexapp.plexmediaserver.plist /var/lib/plexmediaserver/Library/Preferences/

Don’t forget to delete the contents of the plugin directory as these are specific to the operating system Plex is installed on. (You might also want to delete the contents of the update directory given it’s likely to contain updates for a non-linux OS)

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

rm *-Rf

Update owner of newly copied files (plex on ubuntu uses a user and a group called plex to operate).

chown plex.plex /var/lib/plexmediaserver -Rfv

Also, ensure your permissions on the NAS are set correctly.  This is out of scope of this since it get’s quite complicated, however the command chmod is what you’re after and it’s best if you avoid your NAS GUI.

If you mess up your permissions, they should be:

drwxr-xr-x  3 plex    plex  for all of the directory except the Preferences.xml file, which should be: -rw——-  1 plex plex

service plexmediaserver start

Also note the correct procedure to set up your plex media permissions here.

Configure Plex to see the new library in the new Linux mount points you just created

Edit your Library settings

Login to your plex installation through your web browser

In your web browser, go to: http://192.168.1.1:32400/web/index.html

Hover over the Movies (or whatever part you’re trying to migrate) with your mouse.  A pencil icon will show up,click on this.

Choose the Add folders option on the left hand side

KEEP ALL EXISTING LOCATION(S) IN PLACE and add your new location(s) by clicking, ‘Browse for Media Folder’

Choose the appropriate locations you created previously such as /mnt/Video

Click save changes, and if a library rescan doesn’t start, make sure you start one manually.

Once complete, turn on the ‘ ‘Empty Trash Automatically After every scan’ check box in Plex Server / Library page’ again and then you can safely remove the previous library mount locations through the steps above, this will get rid of any dead links to the former video location.

Repeat this for as many library sections as you have.

[/vc_tta_section][vc_tta_section title=”Final Word” tab_id=”1483657035357-36e2d8d1-b325e50c-cffe9549-9db4″][vc_custom_heading text=”Final Word”]

Plex is a powerful media center, but it’s also a powerful media server.  In this configuration, it’s a true server that holds it’s own like no other product can.

If you have an Apple TV, take a look at our Plex with ATV guide here.

Marshalleq

[/vc_tta_section][/vc_tta_tabs]

Popular Articles

Raspberry Pi 3

Raspberry Pi Disk Images – Definitive List

2
This page attempts to list all the Raspberry Pi disk images known to currently exist from around the web, providing direct links to download...
Port Scan Test

How to check port forwarding is working

1
Problem-Outcome Summary This guide applies to:Any router or firewall you may have such as:DLink, Asus, TP Link, Linksys, Synology, Apple, Belkin, Buffalo, Cisco,...
Raspberry Pi Audio Hardware

Raspberry Pi audio HAT’s (Hardware Attached on Top) – Definitive List

0
Summary Back in July 2014, Raspberry Pi announced the then new, Raspberry Pi 2 followed soon after by the announcement of HaTs (Hardware Attached on...
How to set Plex permissions on Linux / NAS devices

How to set Plex permissions on linux or NAS devices

9
Problem / Outcome SummaryThis how to guide will show you how to properly set up Linux file permissions for Plex Media Server Please...
How To Install Logitech Media Server on Ubuntu Linux

How to install Logitech Media Server on Ubuntu Linux

0
Problem / Outcome SummaryThis how to guide will enable you to install Logitech Media Server on Ubuntu Linux For how to install Logitech...
spot_img

Related Stories

Stay on op - Ge the daily news in your inbox