sudoedit.com!

Media Server

Have you ever wanted to set up your own video streaming service on your home or work network? This simple guide will help you set up a media server using Ubuntu 14.04 and Plex. The setup for Plex on Ubuntu is incredibly easy and is a great way to back up your existing video, music and picture library in a way that will allow you to share the content with anyone on or off your network.

Step 1 - Download the installer

Make sure you are in your home directory.

cd ~/

We will be using wget to download the installation package from Plex. Since wget downloads files to the current working directory it is good practice to ensure that the package is downloaded in the home directory.

wget https://downloads.plex.tv/plex-media-server/0.9.14.6.1620-e0b7243/plexmediaserver_0.9.14.6.1620-e0b7243_amd64.deb

Step 2 - Install Plex

sudo dpkg -i plexmediaserver_0.9.14.6.1620-e0b7243_amd64.deb

Installing this package will create a user called "plex" on your server. You can verify that the user was created by checking the /etc/passwd file.

vim /etc/passwd

You should see a line in that file similar to the following:

plex:x:118:127::/var/lib/plexmediaserver:/bin/bash

Exit the file by typing :q! and press enter.

Step 3 - Create the directory structure

Plex reads from specific directories and wants to see your files named in a specific way in order to pull meta data about movies and music from the internet. We will create 3 directories to hold: Movies, Music, and Pictures.

sudo mkdir -p {/Plex/Movies,/Plex/Music,/Plex/Pictures}

The -p option for mkdir will create parent directories if they don't already exist. In this case the Plex directory will be created. The squiggle brackets {} group our directory's so that we can create multiple folders at once.

Plex requires read and execute permissions on the directories we just created, and on any files placed in those directories.

sudo chown -R plex:plex /Plex
sudo chmod -R ug+rx /Plex 
sudo chmod -R g+s /Plex

These commands change the owner of the Plex directory to the plex user and modify the permissions to allow the plex user and group to read and execute files in the directory. Later when you add files to any of these directories they should inherit the plex group so that you will not need to change permissions manually on each file.

At this point you can move any files you want to share from your media server into the appropriate directory. If you don't have any files ready then you can move them at another time.

File names

In Plex file names are very important. Movies for instance should be named as follows: "Name of Awesome Movie (year of release).mp4". For example "My Movie (2016).mp4"

Prevent accidental deletion

I like to protect my library from accidental deletion by setting the "i" (immutable) option in the file attributes.

sudo chatter +i /Plex/Movies/My \Movie \(2016).mp4

Setting the immutable file attribute will prevent all users, even root, from deleting or modifying the file.

Step 4 - Don't forget the firewall

Plex uses port 34200 so in Ubuntu 14.04 we will need to open that port before our media server will work.

sudo ufw allow 34200/tcp

Step 5 - Connect to the server

Open a web browser and go to the following address: http://yourserveripaddress:34200/web

The colon in the address is to specify the port number. You should now see a web page that looks something like this.

sudoedit.com!

Walk through the set up screens and select your media libraries. Once you have completed the set up and created a user account (which is free) from www.plex.tv you will be able to stream Movies, Music, TV shows, and Pictures from pretty much any device on your network.