How to Install Plex Media Server on Linux Mint 22, 21 or 20

Plex Media Server is a robust and versatile media management platform that allows you to organize and stream your personal media collections to any device, including videos, music, and photos. Plex offers a range of advanced features, such as automatic metadata fetching, support for various media formats, live TV and DVR capabilities, and remote access. Its intuitive web interface and a wide array of client applications ensure a seamless experience across different devices.

To install Plex Media Server on Linux Mint 22, 21, or 20, you can use the official APT repository provided by Plex, which includes the latest stable and development builds. This guide will walk you through the installation process using the command-line terminal.

Update Linux Mint Before Installing Plex

Start by updating your Linux Mint system to ensure a smooth installation process. This ensures all existing packages are up to date:

sudo apt update && sudo apt upgrade

Install the Required Packages for Plex

Plex installation requires some additional packages. Install them by running the following command:

sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y

These packages will provide the tools for handling the Plex repository, including secure connections and GPG key management.

Import Plex APT Repository

Add the Plex repository to your Linux Mint system to install Plex from the official source. This ensures you install and update the software directly from the official repository using the APT package manager.

First, open your terminal and import the Plex GPG key with the following command:

curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key | gpg --dearmor | sudo tee /usr/share/keyrings/plex.gpg > /dev/null

This command downloads the Plex GPG key, which is used to verify the authenticity of the packages from the repository.

Next, add the Plex repository to your system:

echo deb [signed-by=/usr/share/keyrings/plex.gpg] https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list

This command creates a new file in the sources.list.d directory with the necessary information about the Plex repository.

Finalize Installation of Plex Media Server via APT command

Before installing Plex, update your package index to include the newly added Plex repository:

sudo apt update

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

sudo apt install plexmediaserver -y

During the installation, you may see a prompt asking if you want to replace the imported repository list with Plex. Type “N” to proceed with the installation, as you do not want to replace the imported repository list. This is because the correct signed-by GPG key is already in place.

Verify Plex Media Server Installation and Service Status

By default, the Plex Media service should start automatically. To verify this, use the following systemctl command to check the status:

systemctl status plexmediaserver

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

sudo systemctl start plexmediaserver

To ensure Plex Media Server starts automatically on system boot, enable the service with this command:

sudo systemctl enable plexmediaserver

If you need to restart the Plex Media Server service for any reason, use the following command:

sudo systemctl restart plexmediaserver

Configure UFW Firewall For Plex Media Server

Securing your Plex Media Server is crucial, especially when you plan to access it remotely or allow others to access it. UFW (Uncomplicated Firewall) is a great way to protect your server.

Enable UFW Firewall

First, check if UFW is installed on your system. If not, install it using the following command:

sudo apt install ufw -y

Next, enable UFW with this command:

sudo ufw enable

Add Plex Media Server Port Rules

Add the default Plex Media Server port (32400) to the UFW rules. You can customize the port later if you wish. If you change the Plex Media Server dashboard port, delete this rule and add a new one.

sudo ufw allow 32400

Additional UFW Rules for Plex

Plex Media Server uses several additional ports for different services and connections. To allow them through the UFW firewall, use the following commands:

sudo ufw allow 1900/udp
sudo ufw allow 3005/tcp
sudo ufw allow 5353/udp
sudo ufw allow 8324/tcp
sudo ufw allow 32410:32414/udp

Here’s a brief explanation of the ports and their purposes:

  • 1900/udp: Used for the discovery of Plex Media Server by clients over the network.
  • 3005/tcp: Required for Plex Companion, a feature that allows you to control Plex playback from a mobile device.
  • 5353/udp: Used for mDNS (Multicast Domain Name System) to help Plex discover devices on the local network.
  • 8324/tcp: Required for the Plex DLNA server.
  • 32410:32414/udp: Used for media streaming to clients.

Adjust your UFW rules if you customize any of the ports mentioned above.

Configure Plex Headless Server SSH

If you’ve installed Plex Media Server on a remote headless server or another Linux Mint desktop to which you don’t always have local access, you’ll need to set up an SSH tunnel on your local computer for the initial setup. This allows outside connections to access the Plex server.

Set up the SSH Tunnel

Replace {server-ip-address} with the actual IP address of your server, for example, 192.168.50.1.

Example:

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

If you’re new to SSH and haven’t installed it yet, you can do so with the following commands:

sudo apt install openssh-server -y
sudo systemctl enable ssh --now

Access Plex Media Server via SSH Tunnel

Now you can access the Plex Media Server by opening the following address in your web browser:

http://localhost:8888/web

Or use the alternative address if the above one does not work:

https://localhost:8888/web/index.html#!/setup

The SSH tunnel will redirect the HTTP request to http://localhost:32400/web on the remote server.

Access Plex Media Server Remotely

Once you’ve completed the initial setup, you can access your Plex Media Server using your remote server’s IP address:

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

Configure Plex Media Server via WebUI

Now that Plex is installed on your system, you must 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/web

If these two do not work, try changing the ends with:

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

Now, you can log in using an existing social media account listed above or with your email 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 briefly explains what Plex is and how it works. Click “GOT IT!” to proceed to the next page.

Note: Firefox users may see a message prompting them to enable DRM depending on their internet browser. This choice is necessary; without it, Plex WebUI may not work correctly.

Click GOT IT! to proceed.

Step 2: Optional Plex Pass

Next, you will be prompted to upgrade to Plex Pass, which is optional. Plex Pass offers benefits like HDR options and access to beta builds. If you want to skip this, click the “X” in the top right-hand corner. You can always set this up later.

Step 3: Server Setup

Configure your server name, which can be anything you desire. You also have the option to disable “Allow me to access my media outside my home.” By default, access to outside media is enabled; if you don’t plan to do this, untick the feature.

Once configured, click the NEXT button.

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.

Now select the type of media you want your folders to be organized into, such as TV shows, movies, music, etc.

Click the “NEXT” button to proceed to add folders.

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

Once the folder is added, the Advanced options will appear, where you can further customize Plex to your liking.

When you’re done, click “ADD LIBRARY” to continue with the initial configuration setup installation.

Step 5. Finishing up

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

The next screen informs you that you’re all set. Click the “DONE” button to proceed to the Plex Dashboard.

Now, you will arrive at your Plex Dashboard.

Configure 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 internal and external secondary hard drives. This is partly due to Plex creating a dedicated user account named plexuser, which needs read and execute permission on your media directories.

Linux Mint permissions can be set using chown or setfacl; both are effective. Below are some examples of how to apply these commands.

Setfacl Examples

To set permissions using setfacl, execute the following commands:

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 Examples

To set permissions using chown, execute the following commands:

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

Or set permissions for individual files in the hard drive if other folders are present that you do not want Plex to access:

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

Installing ACL Package (if necessary)

If the commands above are not working, you may need to reinstall the ACL package if it is missing from your system:

sudo apt install acl -y

Configure Nginx Reverse Proxy

Setting up a reverse proxy allows you to access Plex Media Server from a remote computer or network. In this example, we will set up an Nginx proxy server.

Install Nginx

First, install Nginx with the following command:

sudo apt install nginx -y

By default, Nginx should be enabled. If it is not activated, use the following command:

sudo systemctl enable nginx --now

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

systemctl status nginx

Create a Plex Server Block

Create a new server block as follows:

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

You will need an active domain name and need to create a sub-domain. Once done, 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).

Test Nginx Configuration

Perform a dry run to ensure there are no errors in the Nginx configuration or your server block:

sudo nginx -t

If everything is working correctly, the 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 Reverse Proxy with Let’s Encrypt SSL Free Certificate

It would be best to run your Nginx on HTTPS using an SSL certificate. You can use Let’s Encrypt, a free, automated, 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 creating your certificate:

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

This setup includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Make sure to adjust the email and domain name to your requirements.

Your URL will now be https://plex.example.com instead of http://plex.example.com. If you use the old HTTP URL, it will automatically redirect to HTTPS.

Set Up Automatic Certificate Renewal

Optionally, you can set a cron job to renew the certificates automatically. Certbot offers a script that does this automatically. 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 the certificate should auto-renew. This should be checked daily at a minimum, and if the certificate needs to be renewed, the script will update the certificate.

Add the following line to your crontab:

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

This command will check for certificate renewal at midnight daily. If a certificate is due for renewal, it will automatically update it. This ensures that your SSL certificate stays up to date and your reverse proxy remains secure.

Managing Plex Media Server

Update Plex Media Server on Linux Mint

Plex Media Server can be updated using the standard apt update command, which is commonly used to update packages on your system.

Check for updates

To check for updates, run the following command:

sudo apt update

Upgrade Plex Media Server

If an update is available, use the upgrade command to update Plex Media Server:

sudo apt upgrade plexmediaserver -y

Remove Plex Media Server

If you no longer wish to use Plex and want to remove it from your Linux Mint system, follow these steps.

Uninstall Plex Media Server

Execute the following command to remove Plex Media Server from your system:

sudo apt remove plexmediaserver

Disable Nginx reverse proxy (if applicable)

If you installed the Nginx reverse proxy, remember to disable it and, if necessary, delete the configuration file associated with your domain.

To disable the Nginx reverse proxy, run the following command:

sudo systemctl disable nginx --now

To remove the configuration file, use the following:

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

Finally, reload Nginx to apply the changes:

sudo systemctl reload nginx

Conclusion

With Plex Media Server successfully installed on your Linux Mint system, you can efficiently manage and stream your media collections. Using Plex’s official APT repository ensures you stay up-to-date with the latest stable and development builds, giving you access to new features and improvements. Enjoy the powerful capabilities and flexibility that Plex Media Server offers for your media streaming needs.

Leave a Comment