How To Setup Plex Server Ubuntu 18.04 Bionic Beaver

Step 1: Install Plex Server

1.1a Import the repository’s GPG key

curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add - 

1.1.b Add the Plex APT repository to software repository

echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list 

1.1.c Update system packages

sudo apt update -y

1.2.a Install Plex

sudo apt install plexmediaserver

1.2.b Verify Plex service

sudo systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server for Linux
   Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-11-01 21:20:03 CET; 23h ago
  Process: 3167 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"
 Main PID: 3179 (sh)
    Tasks: 115 (limit: 2320)
   CGroup: /system.slice/plexmediaserver.service
           ├─3179 /bin/sh -c LD_LIBRARY_PATH=/usr/lib/plexmediaserver "/usr/lib/plexmediaserver/Plex Med
           ├─3180 /usr/lib/plexmediaserver/Plex Media Server
           ├─3192 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-ecd60044
           ├─3327 /usr/lib/plexmediaserver/Plex Tuner Service /usr/lib/plexmediaserver/Resources/Tuner/P
           ├─3328 /usr/lib/plexmediaserver/Plex DLNA Server
           ├─3352 Plex Plug-in [com.plexapp.agents.thetvdb] /usr/lib/plexmediaserver/Resources/Plug-ins-
           ├─3470 Plex Plug-in [com.plexapp.agents.plexthememusic] /usr/lib/plexmediaserver/Resources/Pl
           ├─4058 Plex Plug-in [com.plexapp.agents.opensubtitles] /usr/lib/plexmediaserver/Resources/Plu
           ├─4062 Plex Plug-in [com.plexapp.agents.themoviedb] /usr/lib/plexmediaserver/Resources/Plug-i
           └─4063 Plex Plug-in [com.plexapp.agents.plexmusic] /usr/lib/plexmediaserver/Resources/Plug-in

Nov 01 21:20:03 plex.home.local systemd[1]: Starting Plex Media Server for Linux...
Nov 01 21:20:03 plex.home.local systemd[1]: Started Plex Media Server for Linux.

Step 2: Create a UFW application profile

2.1.a Create a application profile for Plex firewall rules

sudo nano /etc/ufw/applications.d/plexmediaserver
# Paste the rules below!


[plexmediaserver]
title=Plex Media Server (Standard)
description=The Plex Media Server
ports=32400/tcp|3005/tcp|5353/udp|8324/tcp|32410:32414/udp

[plexmediaserver-dlna]
title=Plex Media Server (DLNA)
description=The Plex Media Server (additional DLNA capability only)
ports=1900/udp|32469/tcp

[plexmediaserver-all]
title=Plex Media Server (Standard + DLNA)
description=The Plex Media Server (with additional DLNA capability)
ports=32400/tcp|3005/tcp|5353/udp|8324/tcp|32410:32414/udp|1900/udp|32469/tcp

Exit & Save

2.2.a Update the firewall profile

sudo ufw app update plexmediaserver

2.2.b Apply the new firewall rules

sudo ufw allow plexmediaserver-all
root@plex:~$ sudo ufw app update plexmediaserver
root@plex:~$ sudo ufw allow plexmediaserver-all
Rule added
Rule added (v6)
origin@plex:~$

2.2.c Verify firewall rules

sudo ufw status verbose
--                         ------      ----
888                       ALLOW IN    Anywhere
123/udp                    ALLOW IN    Anywhere
8888                       ALLOW IN    Anywhere
32400/tcp (plexmediaserver-all) ALLOW IN    Anywhere
3005/tcp (plexmediaserver-all) ALLOW IN    Anywhere
5353/udp (plexmediaserver-all) ALLOW IN    Anywhere
8324/tcp (plexmediaserver-all) ALLOW IN    Anywhere
32410:32414/udp (plexmediaserver-all) ALLOW IN    Anywhere
1900/udp (plexmediaserver-all) ALLOW IN    Anywhere
32469/tcp (plexmediaserver-all) ALLOW IN    Anywhere
888 (v6)                   ALLOW IN    Anywhere (v6)
123/udp (v6)               ALLOW IN    Anywhere (v6)
8888 (v6)                  ALLOW IN    Anywhere (v6)
32400/tcp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)
3005/tcp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)
5353/udp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)
8324/tcp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)
32410:32414/udp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)            
1900/udp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)
32469/tcp (plexmediaserver-all (v6)) ALLOW IN    Anywhere (v6)

 

Step 3: Configure the Plex server

3.1 Create directories to store Plex media files

sudo mkdir -p /etc/plexmedia/{movies,series}

3.2 Authorize Plex user to access media files

sudo chown -R plex: /etc/plexmedia

3.3 Open the Plex web portal

http://localhost:32400/web/index.html

NOTE: You need to be on the same network

Useful Commands

Stop Plex service

sudo systemctl stop plexmediaserver

Start Plex service

sudo systemctl start plexmediaserver

Display status for Plex service

sudo systemctl enable plexmediaserer

Donate