Install Plex and PlexWatch on Ubuntu Server

Do you want to host your own Netflix? Plex has you covered!

I’ve always been a huge fan of XBMC/Kodi and have been running it on my media center for as long as I can remember. While it’s probably the best open-source media player around, it doesn’t support transcoding or streaming content to another device. This is where Plex comes in and trust me it’s amazing at that!

Preparing the server

Even though Plex is available as a NAS package for quite a few systems (including Synology), I highly recommend to install it on a standalone Ubuntu Server instead. While using the Synology DSM package on XPenology I encountered a lot of issues with the performance, especially while transcoding HD content.

In this tutorial I’ll use a Ubuntu Server 14.04.3 (64-bits) virtual machine running on ESXi 6.0. According to the recommended requirements for transcoding HD content I’ve assigned 2GB of memory and 2 cores per socket, leaving all other parameters at their default values. The installation of Ubuntu Server should be straight forward so I won’t cover that here. Just accept the defaults and login when prompted.

Installing or updating Plex

Most guides will instruct you to install a non-official repository, but there’s really no point in doing that. Just head over to the Plex website and copy the URL to the latest installer for Ubuntu (Linux). Once you have the URL in your clipboard you can use Putty to login to your server and run the following command in sequence:

wget -O plex.deb <url to .deb file>
sudo dpkg -i plex.deb && rm plex.deb

Now Plex should be installed and available from http://ip-of-server:32400/web.
If you want to access Plex from outside your network you’ll want to assign a static IP address to your Ubuntu Server and port forward port 32400 to your static IP.

Configure a static IP address

In order to configure a static IP address (recommended), you’ll need to edit your interfaces file similar to this (change the values to match your network).

sudo nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.1.150
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1

In this case my routers IP address is 192.168.1.1 and Plex will be using 192.168.1.150. Now the only thing you’ll have to do is adding a port forwarding rule on your router. This step differs quite a lot depending on your router, so if you have any issues please let me know.

Accessing your media

The easiest way of accessing your media is by sharing it using the windows file service (SMB protocol). Create a new user with a random password and use that to mount this share on the Plex server. This is done in two steps. Create a directory and mount the share using fstab.

sudo mkdir /mnt/media && sudo nano /etc/fstab

Add the following to the end of the file and remember to replace all the uppercase placeholders.

//IP-OF-SERVER/MEDIASHARE /mnt/media cifs username=USERNAME,password=PASSWORD,iocharset=utf8,sec=ntlm 0 0

Install PlexWatch

PlexWatchWebPlex offers a lot of features, but unfortunately it doesn’t offer any useful usage statistics. Fortunately there is an awesome open-source solution for that on GitHub. In this chapter I’ll show you how to install both PlexWatch (for generating statistics) and PlexWatchWeb (graphical representation of the statistics). First we need to install and configure PlexWatch in order to generate the necessary statistics.

Install the requirements.

sudo apt-get install libwww-perl libxml-simple-perl libtime-duration-perl libtime-modules-perl libdbd-sqlite3-perl perl-doc libjson-perl

Download PlexWatch, update the permissions and create the config file.

sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/plexWatch.pl
sudo wget -P /opt/plexWatch/ https://raw.github.com/ljunkie/plexWatch/master/config.pl-dist
sudo chmod 777 /opt/plexWatch && sudo chmod 755 /opt/plexWatch/plexWatch.pl
sudo cp /opt/plexWatch/config.pl-dist /opt/plexWatch/config.pl

Verify the installation by issuing the follow command. You shouldn’t see any output from it.

/opt/plexWatch/plexWatch.pl

Finally add the script to cron so it’s executed every minute.

crontab -e
* * * * * /opt/plexWatch/plexWatch.pl

Install PlexWatchWeb

While PlexWatch creates the statistics, it doesn’t provide a user interface. Next we’re installing PlexWatchWeb.

Install the requirements.

sudo apt-get install apache2 unzip php5 php5-sqlite php5-curl php5-json

Download PlexWatchWeb and move it to your webserver root directory.

wget -O plexwatchweb.zip https://github.com/ecleese/plexWatchWeb/archive/dev.zip
unzip plexwatchweb.zip && cd plexWatchWeb-master/
mv * /var/www/html/
rm /var/www/html/index.html

Now you should be able to navigate to http://ip-of-server/plexWatch and enjoy your stats.

 

Share this:

One comment, add yours.

Avatar

matt ward

the world of Perl has moved on a bit during the last 4 years … this plexWatch has stood up well that entire time – THANKS!

however, as time and Perl march onward, i’m starting to see warnings about a few lines in plexWatch.pl that i am unfamiliar with:

Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <– HERE in m/{{ <– HERE newline}}/ at /opt/plexWatch/plexWatch.pl line 760.
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <– HERE in m/{{ <– HERE all_details}}/ at /opt/plexWatch/plexWatch.pl line 764.
Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <– HERE in m/\s*{{ <– HERE all_details}}\s*/ at /opt/plexWatch/plexWatch.pl line 765.

i am unfamiliar with the Regex usage of:

s/{{newline}}/\n/g

i basically know what it wants to do … but what does the double-curly-braces do?

normally i would go with something like:

s/{\{newline\}}/\n/g;

but i worry that the double braces are supposed to special.

advice?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.