Category Archives: plex

How To Stream Music & Video With Plex on FreeBSD

Introduction

Plex is a great piece of software, if you’ve never heard it before think of it as an easy to use service that runs on a computer that streams just about any format of audio/video to a Smart TV, Apple TV, Roku, or modern console. You can even easily configure it so that your iOS device can stream content from your media server across the Internet. Perfect!

If you are running a small blog on a VPS instance, chances are you have way more bandwidth, disk space, RAM, and CPU than you need for the blog. I’ve put together this short tutorial on how to install & configure Plex on your VPS to stream your music/video collection from that instead of your home computer (for example, if you want to stream your music library without hitting your residential data cap at home!).

Prerequisites

Before you begin this guide you’ll need the following:

Freebsd 10.x Droplet

A non-root user with sudo privileges (https://www.digitalocean.com/community/tutorial_series/getting-started-with-freebsd) explains how to set this up.)

Up To Date Ports Tree

Step 1 — Updating Ports Tree

The Ports Tree is updated constantly, you should update your system’s local copy on a regular basis. To do this manually, execute the following command:

sudo portsnap fetch update

Step 2 – Install Plex

Plex doesn’t have a lot of prerequisites, the easiest way to install is to run:

sudo pkg install plexmediaserver

After the package has been installed, the installation process tells you how to set the plexmediaserver service to start automatically at boot as well as how to manually start it. We’ll perform both commands now:

sudo sysrc plexmediaserver_enable=YES

and

sudo service plexmediaserver start

Step 3 – Configure Plex

root@freebsd:~ # pkg install plexmediaserver
Updating FreeBSD repository catalogue…
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
plexmediaserver: 1.0.0.2261
compat9x-amd64: 9.3.903000.20160608

Number of packages to be installed: 2

The process will require 170 MiB more space.
65 MiB to be downloaded.

Proceed with this action? [y/N]: y

After downloading and installing, it will prompt you with the following information:

Message from plexmediaserver-1.0.0.2261:
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

multimedia/plexmediaserver includes an RC script:
/usr/local/etc/rc.d/plexmediaserver

TO START PLEXMEDIASERVER ON BOOT:
sysrc plexmediaserver_enable=YES

START MANUALLY:
service plexmediaserver start

Once started, visit the following to configure:
http://localhost:32400/web

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

NOTES: If there is an issue getting to the initial setup screen of the server after adding your IP to the allowed network setting, try a different browser or close all tabs and windows and empty cookies.

If there is a problem “Claiming” the new server, log out of plex and back in again.

If there is a problem with the new server showing up on iOS, sign out of your account in the plex app and force kill it. Re-launch and log back in.

Installing Plex on a VPS

Plex is a great piece of software, if you’ve never heard it before think of it as an easy to use service that runs on a computer at home that streams just about any format of audio/video to a smart TV, Apple TV, Roku, or modern console. You can even easily configure it so that your iOS device can stream content from your media server across the Internet. Perfect!

However, maybe your home Internet upload speed is not very good. Or you have a data cap. Or you are trying to upload a massive amount of data to Amazon or Backblaze for backups and you don’t need to make that process even slower by using precious upload bandwidth for Plex. This site is hosted on a VPS instance with way more disk space than I need for a small blog, so I’ve plenty of disk space and bandwidth to stream my music from that instead of my from my home computer.

First of all, it’s as simple as downloading the .deb file from Plex’s site and following the simple install instructions to get the service installed. Really the one and only hiccup I ran into (and the reason I decided to write this blog post about it) is that once you’ve installed the service it is expecting you to configure it by visiting http://localhost:32400/web. However it’s a command line only Linux environment and Lynx doesn’t get the job done (I tried).

After much Googling, all I could find was references to using ssh to setup a tunnel and changing your browser’s proxy setting so that the Plex service thought you were accessing it from the local machine. That was, in my experience, a bunch of crap and never worked. Eventually I found a forum post that simply said to edit the Plex config file that restricted the initial setup to only happen from the local host. A quick trip to https://www.whatismyip.com and a quick edit in vi, and I was in business.

Here’s all you have to do:

  • Change into /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/
  • Edit the Preferences.xml file
  • There should be two lines, the second line is very long. It starts with Preferences in brackets.
    • After that tag, add the following:
      • allowedNetworks=”your.ip.address.here/your.subnet.mask.here”
  • For example, you’d put allowedNetworks=”1.2.3.4/255.255.255.255″
  • Save the file, restart the Plex service, and POOF! You can now login and configure the server via http://server-ip-address:32400/web

After you configure the service, be sure you remove the “allowedNetworks” tag from the XML file and restart the service.