In this post, we will see how can install our own Plex server instance on our Ubuntu (or any Debian based) system.

Plex allows us to have our own media library (movies, tv shows, music, images, videos) that we can access from any device in our local network or the outside world if we enable it.

The only thing that we will need, except for a linux server, is a free Plex account that we will see where you can create, later in the process.

Download Plex

  • Open on a browser plex downloads page and choose your platform
  • Choose distribution, and copy download link
  • Download on server with wget:
wget https://downloads.plex.tv/plex-media-server-new/1.20.1.3252-a78fef9a9/debian/plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb

Install with dpkg

sudo dpkg -i plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb

Check status

systemctl status plexmediaserver

If Plex server isn’t running start it manually:

sudo systemctl start plexmediaserver

Enable Plex Repository

See list of files from package:

dpkg -L plexmediaserver

Open this file:

sudo vim /etc/apt/sources.list.d/plexmediaserver.list

Uncomment only the last line:

#wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add -  deb https://downloads.plex.tv/repo/deb/ public main

Import Plex public key to apt package manager:

wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add -

Update software repository index:

sudo apt update

Permissions & Ownership (on shared folders)

Samba Directory

Add plex user to Samba Users

Instead of creating a new user for Samba, add plex user to sambashare:

sudo gpasswd -a plex sambashare

Creating Samba Users Home directory

Create the plex’s user home directory inside samba/ directory and set the directory ownership to user plex and group sambashare:

sudo mkdir samba/smbplex
sudo chown plex:sambashare samba/smbplex
sudo chmod 2770 samba/smbplex

Add plex user to Samba Database

Add the plex user account to the Samba database by setting a password. Once the password is set enable the Samba account:

sudo smbpasswd -a plex
sudo smbpasswd -e plex

Configuring Samba Shares

Open the Samba configuration file:

sudo vim /etc/samba/smb.conf

and append the section at the end of the file:

[smbplex]
        path = /media/wd-2TB/samba/smbplex
        browseable = yes
        # guest ok = yes
        read only = no
        force create mode = 0660
        force directory mode = 2770
        valid users = plex @sambashare @plex

Restart Samba Services

sudo systemctl restart smbd
sudo systemctl restart nmbd

Regular Directory

  • Make sure the group owner is a group that the plex user is in.
  • Give permission with setfacl command.

Plex Media Server Initial Setup

  • Open on a browser this link (replace the IP with your server’s IP): http://192.168.1.99:32400/web

Now it is ready for the GUI setup on the browser:

  • Sign in with your account (or create a new one if you don’t have one)
  • Give a name to your server
  • Select “Allow plex to access my media outside my home”
  • Select “Add Library”
  • After selecting the folders you want to share with plex
  • Select “Next” and “Done”.

Further stuff

  • Reverse Proxy
  • HTTPS
  • Upgrade