Summary

  Subject:

Create a Plex Media Server

  Updated:

2023-01-21

  Author:

Tim Hammond ([email protected])

Derek Pasnick ([email protected])

  Operating Systems:

Rocky 8

  Background:

This guide was written to setup a stand-alone Plex sever software. It is assumed that a seperate NFS has already been setup.

Between Plex updates, the preferences.xml has a nasty habbit of corrupting itself. Sometimes it is recoverable, other times not so much. The idea here is to mitigate outagess.

 

Table of Contents

VM Config

VM Specifications:

  • CPU: 1vCPU (4 cores)
  • RAM: 16 GB
  • HD: 100 GB

Change the hostname:

sudo hostnamectl set-hostname plex01.domain.local

Update the IP:

sudo sed -i 's/192.168.30.199/192.168.30.104/g' /etc/sysconfig/network-scripts/ifcfg-ens192 sudo cat /etc/sysconfig/network-scripts/ifcfg-ens192

How-Tos for each of items listed below are avaiable in the Linux section. Before proceeding, make sure you have read and/or completed the following:

  • VM has been joined to the Active Directory domain
  • A NFS server has been created to host the media
  • The NFS server has the local storage configured (most likely LVM)
  • The NFS server is configured to share NFS exports

Install

Install the NFS client so you can mount NFS shares.

sudo dnf -y install nfs-utils

Download Plex from plex.tv from: https://www.plex.tv/media-server-downloads/

Install Plex

sudo dnf -y install plexmediaserver*.rpm

Add Plex to the startup routine.

sudo systemctl enable plexmediaserver

Start the Plex service.

sudo systemctl start plexmediaserver

Firewall Setup

Append the following text to the firewall config file:

sudo tee -a /etc/firewalld/services/plexmediaserver.xml >/dev/null <<EOF <?xml version="1.0" encoding="utf-8"?> <service version="1.0"> <short>plexmediaserver</short> <description>Plex TV Media Server</description> <port port="1900" protocol="udp"/> <port port="5353" protocol="udp"/> <port port="32400" protocol="tcp"/> <port port="32410" protocol="udp"/> <port port="32412" protocol="udp"/> <port port="32413" protocol="udp"/> <port port="32414" protocol="udp"/> <port port="32469" protocol="tcp"/> </service> EOF

Apply the firewall changes:

sudo firewall-cmd --permanent --add-service=plexmediaserver sudo firewall-cmd --reload sudo firewall-cmd --list-all

Create NFS Mount Points

To get a list of NFS shares:

showmount -e nfs01.domain.local

Create a mount point for the NFS shares from nfs01.

sudo mkdir -p /mnt/nfs01-media

Mount the shares.

sudo mount -t nfs -o user=svc-Plex nfs01.domain.local:/mnt/nfs /mnt/nfs01-media

Add the NFS share to the fstab so that it is mounted every time so that Plex has access to the media.

sudo tee -a /etc/fstab >/dev/null <<EOF nfs01.domain.local:/mnt/nfs /mnt/nfs01-media nfs defaults 0 0 EOF

To unmount a NFS share:

sudo umount /mnt/nfs01-media

Plex config file and changes

Make a backup of the repo config file.

sudo cp /etc/yum.repos.d/plex.repo /etc/yum.repos.d/plex.repo.bak

Enable updates.

sudo sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/plex.repo

Verify the change.

sudo cat /etc/yum.repos.d/plex.repo | grep -i enabled

Make a backup of the preferances config file.

pBakPath=/home/$(whoami)/ pBakDate=$(date "+%Y-%m-%d") echo $pBakPath echo $pBakDate mkdir -p "$pBakPath/plex_backups" sudo cp "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml" "$pBakPath/plex_backups/Preferences.xml.$pBakDate.bak" sudo chmod 770 -R $pBakPath/plex_backups sudo chown syseng:"domain users" -R $pBakPath/plex_backups

Add server and client networks to the config file.

sudo sed -i 's/"\/>/" LanNetworksBandwidth="192.168.30.0\/24,192.168.31.0\/24" allowedNetworks="192.168.30.0\/24,192.168.31.0\/24"\/>/g' "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

Best to restart before configureing farther.

sudo systemctl restart plexmediaserver

Plex Web Interface Config

The following settings are stored in the "Preferences.xml" file in the in the following path: "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/" Do not for get the quotes as there is a space in the file path. Also note that the network security/allowed networks were already modified in the "Plex config file and changes" section of this run book.

Open a web browser and go to the following website. Once logged in, click on the wrench of the top right of the window. By default, the advanced settings are not shown.

  1. Go to: http://plex01.domain.local:32400/web
  2. Go to the Wrench on the top right of the window
  3. Verify "SHOW ADVANCED" settings is enabled.

Go to: Wrench > Server Name > Settings > General

Friendly name: plex01 Send crash reports to Plex: Unchecked

Go to: Wrench > Server Name > Settings > Library

Scan my library periodically: Checked Library scan interval: Every 12 hours Allow media deletion: Unchecked

Go to: Wrench > Server Name > Settings > Network

Enable server support for IPv6: Not Checked Secure Connections: To be configured later Perferred network interace: ens192 (192.168.30.104) Strict TLS configuration: Checked Remote streams allowed per user : 2 LAN Networks: 192.168.30.0/24,192.168.31.0/24 Terminate Sessions Paused: 60 List of IP addr ... allowed wo auth: 192.168.30.0/24,192.168.31.0/24

Add Libraries

Open a web browser and go to the following website. Once logged in, click on the wrench of the top right of the window. By default, the advanced settings are not shown.

  1. Go to: http://plex01.domain.local:32400/web
  2. Go to the Wrench on the top right of the window
  3. When adding libraries during testing, Plex did not seem to handle having a single library with multiple folders. The solution was to add the sub-folders and not the higher level folder.

Go to: Wrench > Server Name > Manage > Libraries > Click "ADD LIBRARY" > Movies > Browse.

  1. Browse to the path of your content.
  2. Repeat the steps 3-4 above for any additional media required (music, movices, tv, etc.).

Certificate Creation

Certificate creation is out of the scope of this document.

Certificate Install

Upload the plex01.pfx cert to:

/tmp/plex01.pfx

Set the permissions.

sudo chmod 600 /tmp/plex01.pfx sudo chown plex:plex /tmp/plex01.pfx

Move the cert to its proper home.

sudo mv /tmp/plex01.pfx /var/lib/plexmediaserver/plex01.pfx

Make Plex use the cert.

  1. Go to: http://plex01.domain.local:32400/web
  2. Go to: Wrench > Server Name > Network
  3. Click "SHOW ADVANCED" to see the necessary fields.
Secure connections: Required
  1. Enter the following values:
Custom certificate location: /var/lib/plexmediaserver/plex01.pfx Custom certificate encryption key: see keypass Custom certificate domain: https://plex01.domain.local:32400
  1. Save Changes.

References

File naming conventions and permissions

Install SSL cert