Table of Contents

Ubuntu - Plex - Install Plex Media Server

Add the Plex APT repository

curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list

NOTE: This also imports the GPG key for the repository.


Install the Plex Server Package

sudo apt update
sudo apt install plexmediaserver

NOTE: This should install the Plex Media Server.


Verify that Plex is running

sudo systemctl status plexmediaserver

returns:

[sudo] password for peter: 
● plexmediaserver.service - Plex Media Server
     Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-11-19 09:47:32 GMT; 52s ago
    Process: 819 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" (code=exited, status=0/SUCCESS)
   Main PID: 854 (Plex Media Serv)
      Tasks: 61 (limit: 9403)
     Memory: 258.5M
     CGroup: /system.slice/plexmediaserver.service
             ├─ 854 /usr/lib/plexmediaserver/Plex Media Server
...
Nov 19 09:47:32 plex systemd[1]: Starting Plex Media Server...
Nov 19 09:47:32 plex systemd[1]: Started Plex Media Server.

Configure the Firewall

Create or Edit the /etc/ufw/applications.d/plexmediaserver file:

/etc/ufw/applications.d/plexmediaserver
[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

NOTE: This allows traffic on the Plex-specific ports.


Update the FireWall Profiles List

sudo ufw app update plexmediaserver

Apply the new firewall rules

sudo ufw allow plexmediaserver-all

Check that the new firewall rules are applied successfully

sudo ufw status verbose

returns:

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
 
To                         Action      From
--                         ------      ----
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                  
22/tcp                     ALLOW IN    Anywhere                  
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)             
22/tcp (v6)                ALLOW IN    Anywhere (v6)             

NOTE: The port 22 lines may be shown if SSH is enabled.


References

https://linuxize.com/post/how-to-install-plex-media-server-on-ubuntu-20-04/