Page 1 of 1

[HowTo] Install Plex Media Server on VestaCP server

Posted: Thu Sep 13, 2018 5:55 pm
by xorro
Install Plex Media Server

The easiest way to install and manage Plex Media Server on Ubuntu 18.04 is by using the Plex official repository. It requires no technical knowledge and it should not take you more than 20 minutes to install and configure the media server.

Follow the steps below to install the Plex Media Server on your Ubuntu system:

Add the Plex repository

The following commands will add Plex’s GPG key to the apt sources keyring and create a new file containing an entry to the Plex repository:
Ubuntu

Code: Select all

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
CentOS
To enable the Plex repository open your text editor and create a new YUM repository configuration file named plex.repo in /etc/yum.repos.d/ directory:

Code: Select all

nano /etc/yum.repos.d/plex.repo

Code: Select all

[PlexRepo]
name=PlexRepo
baseurl=https://downloads.plex.tv/repo/rpm/$basearch/
enabled=1
gpgkey=https://downloads.plex.tv/plex-keys/PlexSign.key
gpgcheck=1
Install Plex

Now that the Plex repository is enabled, update the apt package list and install the latest version of the Plex Media Server with:

Ubuntu

Code: Select all

sudo apt update
sudo apt install plexmediaserver
CentOS

Code: Select all

sudo yum install plexmediaserver

Code: Select all

sudo systemctl start plexmediaserver.service
sudo systemctl enable plexmediaserver.service
Verify the installation

To verify that the Plex service is running type:

Ubuntu

Code: Select all

sudo systemctl status plexmediaserver

Code: Select all

    ● plexmediaserver.service - Plex Media Server for Linux
Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2018-06-25 10:42:28 PDT; 35min ago
Process: 2544 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: 2556 (sh)
Tasks: 56 (limit: 2321)
CGroup: /system.slice/plexmediaserver.service
CentOS

Code: Select all

sudo systemctl status plexmediaserver

Code: Select all

● plexmediaserver.service - Plex Media Server for Linux
   Loaded: loaded (/usr/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-07-21 22:22:22 UTC; 12s ago
 Main PID: 13940 (Plex Media Serv)
   CGroup: /system.slice/plexmediaserver.service
Adjust the Firewall Rules

Now that you have Plex installed and running on your server you need to make sure your firewall is configured to allow traffic on Plex Media Server specific ports.

If there is not firewall running on your system you can skip this section.

The following steps assume that you are using UFW to manage your firewall:

Ubuntu
Open your text editor of choice and create the following UFW application profile:

Code: Select all

nano /etc/ufw/applications.d/plexmediaserver

Code: Select all

[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
Save the file and update profiles list:

Code: Select all

sudo ufw app update plexmediaserver
Apply the new firewall rules by typing:

Code: Select all

sudo ufw allow plexmediaserver-all
Finally check if the new firewall rules are applied successfully with:

Code: Select all

sudo ufw status verbose

Code: Select all

Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To                         Action      From
--                         ------      ----
22/tcp                     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
CentOS
Now that Plex is installed and running you need to configure your firewall to allow traffic on Plex Media Server specific ports.

If you don’t have firewall enabled on your system, you can skip this section.

Open your text editor of choice and create the following Firewalld service:

Code: Select all

nano /etc/firewalld/services/plexmediaserver.xml

Code: Select all

<?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>
Save the file and apply the new firewall rules by typing:

Code: Select all

sudo firewall-cmd --add-service=plexmediaserver --permanent
sudo firewall-cmd --reload
Finally check if the new firewall rules are applied successfully with:

Code: Select all

sudo firewall-cmd --list-all

Code: Select all

public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: ssh dhcpv6-client plexmediaserver
  ports:
  protocols:
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
Configure Plex Media Server

Before starting the Plex setup wizard let’s create the directories that will store the Plex media files:

Code: Select all

sudo mkdir -p /opt/plexmedia/{movies,series}
The Plex Media Server runs as the user plex which must have read and execute permissions to the media files and directories. To set the correct ownership run the following command.

Code: Select all

sudo chown -R plex: /opt/plexmedia
You can choose any location to store the media files, just make sure you set the correct permissions.

Now we can proceed with the server configuration. Open your browser, type http://YOUR_SERVER_IP:32400/web and you will be presented with the following screen:

Image

In order to use the Plex Media Server you will need to create an account.

Press the Google, Facebook or Email button to create a free Plex account. If you want to access premium features you can purchase a Plex Pass plan.

Once you sign up you will be redirected to the page with information about how Plex works as shown below:

Image

Click on the Got it button.

On the next screen enter your Plex server name, leave the Allow me to access my media outside my home box checked, and click Next.

Image

The next step is to add a media library. Click on the Add Library button.

When the popup window shows, select movies as library type and click Next.

Image

In thew next step click on the Browse for media folder and add the path to the directory that will contain the Movies media files, in our case /opt/plexmedia/movies.

Image

Click on the Add button and then on the Add Library.

You can add as many Libraries as you want.

Image

Click Next, then Done and you will be redirected to the Plex web dashboard.

Image

Now that you have completed the setup wizard, you can start exploring Plex options and all the things it can do.