How to Install Plex Media Server on Linux Mint 20

Plex Media Server is software to store all your digital media content and access via a client application such as your TV, NVIDIA Shield, Roku, Mobile App, and many more platforms. Plex Media Server organizes your files and content into categories. It’s extremely popular with people storing TV Shows and Movie Libraries, and if your connection is good enough, share it with your friends and family. Over time Plex Media Server has grown much and now supports many platforms.

In the following tutorial, you will learn how to install Plex Media Server on Linux Mint 20 series.

Update Linux Mint System

Update your Linux Mint system to make sure all existing packages are up to date:

sudo apt update && sudo apt upgrade -y

Install Dependencies

To complete the tutorial and must of all install and use Plex, you must install the following packages:

sudo apt install apt-transport-https curl wget software-common-properties -y

Install Plex Media Server

To install Plex, you must create a repository file that pulls directly from the Plex repository. This ensures you install and update straight from the official source using the apt package manager.

First, open your terminal, then import the GPG key using the following terminal command:

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

Example output if successful:

OK

Next, import the repository:

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

Before installing Plex, it is good to run the apt update command.

sudo apt update

Now install the Plex Media Server on Linux Mint using the following apt install command:

sudo apt install plexmediaserver -y

Note, during the installation, you will see the following prompt:

How to Install Plex Media Server on Linux Mint 20

Type “N” to proceed with the installation.

By default, the Plex Media service should be automatically started. To verify this, use the following systemctl status command:

systemctl status plexmediaserver

Example output:

How to Install Plex Media Server on Linux Mint 20

If the service is not active, use the following command to start Plex Media Server:

sudo systemctl start plexmediaserver

Next, enable on system boot:

sudo systemctl enable plexmediaserver

To restart the service, use the following:

sudo systemctl restart plexmediaserver

Configure Plex Headless Server SSH

For users with Plex Media Server installed on a remote headless server such as Ubuntu 20.04, you will first need to set up an SSH tunnel on your local computer for initial setup to allow outside connections.

Replace {server-ip-address} with your own, for example 192.168.50.1 etc.

Example:

ssh {server-ip-address} -L 8888:localhost:32400

For users new to SSH, you may need to install it.

sudo apt install openssh-server -y

Next, start the service.

sudo systemctl enable ssh -y

Now you can access the Plex Media Server by accessing the localhost in your web browser.

http://localhost:8888/web

Or the alternative if the above address does not work.

localhost:32400/web/index.html#!/setup

The HTTP request will be redirected to http://localhost:32400/web the remote server through an SSH tunnel. 

Once the initial setup is done, you will access your Plex Media Server with your remote server IP address.

https://{server-ip-address}:32400

Configure Plex Media Server in WebUI

Now that Plex is installed on your system, you need to configure and finish the setup through the WebUI. To access this, open your preferred Internet Browser and navigate to http://127.0.0.1:32400/web or http://localhost:32400/webIf these two do not work, try changing the ends with /web/index.html#!/setup that should fix any errors.

Example:

How to Install Plex Media Server on Linux Mint 20

Now, you can log in using an existing social media account listed above or with your e-mail to register a new account if you are new to Plex. Once logged in, you will begin the initial configuration setup.

Step 1. How Plex Works

The first configuration page describes what Plex is and how it works concisely. Navigate to GOT IT! and left click to proceed to the next page. Note, depending on the Internet Browser you use, Firefox users will notice a message prompting to enable DRM; this choice is needed; without it, Plex WebUI may not work correctly.

Click GOT IT! to proceed.

Example:

How to Install Plex Media Server on Linux Mint 20

Step 2. Optional Plex Pass

Next, you will be prompted to upgrade to Plex Pass possibly. This is optional; however, Plex Pass benefits HDR options and access to Beta builds. If you want to skip-click the “X” on the top right-hand corner, you can always set this up later.

Example:

How to Install Plex Media Server on Linux Mint 20

Step 3. Server Setup

Configure your server name, and you can name this anything you desire along with having the option to disable “Allow me to access my media outside my home.” By default, allowing access to media outside is enabled; if you are not going to do this, untick the feature.

Once configured, click the NEXT button.

Example:

How to Install Plex Media Server on Linux Mint 20

Step 4. Media Library

The Media Library page gives you the option to pre-add your media directories. If you have a media drive or folder ready, click the ADD LIBRARY button.

Example:

How to Install Plex Media Server on Linux Mint 20

Now select the type of media you want your folders to be organized into tv shows, movies, music, and so on. Click the NEXT button to proceed to add folders.

Example:

How to Install Plex Media Server on Linux Mint 20

Click the BROWSE FOR MEDIA FOLDER button and select the media directory.

Example:

How to Install Plex Media Server on Linux Mint 20

The last option is once the folder is added, the Advanced options will appear, here you can further customize Plex to your liking. Once done, click ADD LIBRARY to continue back to the initial configuration setup installation.

Example:

How to Install Plex Media Server on Linux Mint 20

Step 5. Finishing up

Next, hit the NEXT button to finish the initial setup with or without adding a Media Library.

Example:

How to Install Plex Media Server on Linux Mint 20

The next screen informs you that you are all set. Click the DONE button to proceed to Plex Dashboard.

Example:

How to Install Plex Media Server on Linux Mint 20

Now you will arrive at your Plex Dashboard.

Example:

How to Install Plex Media Server on Linux Mint 20

Configure/Setup Media Files & Folders Permissions

During the initial setup, you may have noticed that your media did not appear. You may have problems adding content that will not be picked up with Plex refusing to find the content on your existing hard drives internal and external secondaries. This is partly due to Plex creating a dedicated user account named plexuser, which needs to read and execute permission on your media directories. 

Linux Mint permissions can be set using chown or setfalc; both are good. Some examples of how to apply are below.

setfalc way example:

sudo setfacl -R -m u:plex:rx /media/yourfolder/
sudo setfacl -R -m u:plex:rx /media/yourfolder/tv
sudo setfacl -R -m u:plex:rx /media/yourfolder/movies

chown way example:

sudo chown -R plex:plex /media/yourfolder/

Or individual files in the hard drive if other folders are present that you do not want Plex to touch/access.

sudo chown -R plex:plex /media/yourfolder/tv
sudo chown -R plex:plex /media/yourfolder/movies

If the commands above are not working, you may need to re-install the ACL package if it is missing from your system.

sudo apt install acl -y

Configure/Setup Nginx as a Reverse Proxy

You can set up a reverse proxy to access Plex Media Server from a remote computer or network. In this example, the tutorial will set up an Nginx proxy server.

First, install Nginx:

sudo apt install nginx -y

By default, Nginx should be enabled if it is not activated. use:

sudo systemctl enable nginx --now

Now check to make sure Nginx is activated and has no errors:

systemctl status nginx

Example output:

How to Install Plex Media Server on Linux Mint 20

Now, create a new server block as follows:

sudo nano /etc/nginx/conf.d/plex.conf

You will need an active domain name which can be purchased for as little as 1 to 2 dollars if you do not have one. NameCheap has the best cheap domains going around and if you prefer a .com, use Cloudflare.

After you have created your sub-domain, add the following to the server block file:

server {
      listen 80;
      server_name plex.example.com;

      location / {
          proxy_pass http://127.0.0.1:32400;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

          #upgrade to WebSocket protocol when requested
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "Upgrade";
      }
}

Save the file (CTRL+O), then exit (CTRL+X).

Now do a dry run to make sure no errors in the Nginx configuration or your server block:

sudo nginx -t

If everything is working correctly, example output should be:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Reload Nginx for the change to take effect:

sudo systemctl reload nginx

If you have set up your domain and DNS records to point to your server IP, you can now access your Plex Media Server at plex.example.com.

Secure Nginx with Let’s Encrypt SSL Free Certificate

Ideally, you would want to run your Nginx on HTTPS using an SSL certificate. The best way to do this is to use Let’s Encrypt, a free, automated, and open certificate authority run by the nonprofit Internet Security Research Group (ISRG).

First, install the certbot package as follows:

sudo apt install python3-certbot-nginx -y

Once installed, run the following command to start the creation of your certificate:

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d plex.example.com

This ideal setup includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Just make sure to adjust the e-mail and domain name to your requirements.

Now your URL will be HTTPS://plex.example.com instead of HTTP://plex.example.com.

Note if you use the old HTTP URL, it will automatically redirect to HTTPS.

Optionally, you can set a cron job to renew the certificates automatically. Certbot offers a script that does this automatically, and you can first test to make sure everything is working by performing a dry run.

sudo certbot renew --dry-run

If everything is working, open your crontab window using the following terminal command.

sudo crontab -e

Next, specify the time when it should auto-renew. This should be checked daily at a minimum, and if the certificate needs to be renewed, the script will not update the certificate. If you need help finding a good time to set, use the crontab.guru free tool.

00 00 */1 * * /usr/sbin/certbot-auto renew

Update Plex Media Server

Plex can be updated as per the standard apt update command that you would use most of your time upgrading packages on your system.

To check for updates:

sudo apt update

If one is available, use the upgrade command:

sudo apt upgrade plexmediaserver -y

Remove (Uninstall) Plex Media Server

If you no longer wish to use Plex and want to remove it from your Linux Mint system, execute the following command:

sudo apt autoremove plexmediaserver --purge -y

Note, if you installed the Nginx reverse proxy, do not forget to disable it and, if needed, delete the configuration file of your domain.

Comments and Conclusion

Plex Media Server is an excellent software for media libraries and is easy to maintain with great features that generally are very stable. I have tried many others, such as Emby, and always found myself coming back to Plex. Another great benefit is that Plex has some awesome 3rd party developers doing some community projects that are open source that you don’t see in other communities of this nature.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!