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

In this guide, we delve into the process of installing Plex Media Server on Linux Mint 21 or 20, offering a clear and efficient pathway to transform your computing environment into a robust media management hub. Plex Media Server stands out as a leading choice for organizing and streaming media content, thanks to its seamless integration and user-friendly interface.

Key Features of Plex Media Server:

  • Centralized Media Library: Organize all your media content, including photos, music, and videos, in one accessible location.
  • Cross-Device Streaming: Enjoy your media on various devices, including smartphones, tablets, and smart TVs.
  • Customizable Libraries: Tailor your media collections with personalized organization and naming conventions.
  • Remote Access: Stream your media from anywhere, at any time, with secure remote access.
  • User Management: Set up multiple user profiles, each with unique preferences and access controls.
  • Automatic Metadata Retrieval: Plex enriches your media library with descriptions, artwork, and ratings.

Emphasizing ease of use and efficiency, the following sections will guide you through each step of the Plex Media Server installation on Linux Mint, ensuring you harness these features to their full potential. Stay tuned for detailed instructions, tips, and best practices to elevate your media experience.

Install Plex Media Server on Linux Mint 21 or 20

Step 1: 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

Step 2: 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 necessary tools for handling the Plex repository, including secure connections and GPG key management.

Step 3: Import Plex APT Repository

To install Plex from the official source, you need to add the Plex repository to your Linux Mint system. 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.

Step 4: Install Plex on Linux Mint 21 or 20 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.

Step 5: Verify Plex Media Server

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

systemctl status plexmediaserver
systemctl Status of Plex on Linux Mint
Confirming Plex Media Server is running on Linux Mint

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 on Linux Mint 21 or 20

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.

Step 1: 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

Step 2: 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. Make sure to delete this rule and add a new one if you change the port in the Plex Media Server dashboard.

sudo ufw allow 32400

Step 3: 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.

Remember to adjust your UFW rules if you customize any of the ports mentioned above.

Configure Plex Headless Server SSH on Linux Mint 21 or 20

If you’ve installed Plex Media Server on a remote headless server or another Linux Mint desktop that you don’t always have local access to, 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.

Step 1: 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

Step 2: 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 HTTP request will be redirected to http://localhost:32400/web on the remote server through the SSH tunnel.

Step 3: 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 on Linux Mint 21 or 20

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
Plex Media Server Login on Linux Mint
Logging into Plex Media Server on Linux Mint

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 that depending on the internet browser you use, Firefox users may see a message prompting them to enable DRM; this choice is necessary; without it, Plex WebUI may not work correctly.

Click GOT IT! to proceed.

First Time Welcome Message on Plex Media Server
Welcome message during Plex Media Server setup

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.

Plex Premium Subscription Option
Plex Premium subscription offer during setup

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.

Setting Up Server Name and Access on Plex
Naming and access settings for Plex on Linux Mint

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.

First Time Media Library Setup in Plex
Initial setup of a Plex Media Library

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.

Selecting Media Type for Plex Library
Selecting a media type for new Plex library

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

Adding Folders to New Plex Library
How to add folders to your Plex library

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 back to the initial configuration setup installation.

Advanced Library Settings in Plex
Advanced settings for Plex libraries

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.

Plex Media Server Setup Completion
Plex setup complete on Linux Mint

Now you will arrive at your Plex Dashboard.

Plex Media Server Ready on Linux Mint
Plex Media Server connected and operational

Configure Media Files & Folders Permissions on Linux Mint 21 or 20

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. Some examples of how to apply these commands are below.

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 on Linux Mint 21 or 20

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.

Step 1: 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

Step 2: Create a Plex Server Block on Linux Mint

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).

Step 3: 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.

Step 4: Secure Reverse Proxy with Let’s Encrypt SSL Free Certificate

It is recommended to run your Nginx on HTTPS using an SSL certificate. You can 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 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.

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

Step 5: 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. If you need help finding a good time to set, use the crontab.guru free tool.

Add the following line to your crontab:

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

This command will check for certificate renewal daily at midnight. 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.

First-Time Tips with Plex Media Server on Linux Mint 21 or 20

In this section, we’ll provide some useful tips and tricks to enhance your experience with Plex Media Server on Linux Mint. We’ll cover general tips, customization, and other useful suggestions. Remember, these tips are specifically tailored for Linux Mint users.

General Plex Tips on Linux Mint

  • Organize your media: Ensure that your media files are well-organized in folders, separated by categories like movies, TV shows, music, and photos. This will help Plex automatically identify and sort your content.
  • Plex naming conventions: Adhere to Plex’s recommended naming conventions for your media files to ensure accurate metadata fetching and sorting.
  • Regularly update your library: Keep your library up-to-date by scanning for new content. Plex will automatically update your library when it detects new files, but you can also manually trigger a scan by going to the specific library section and clicking on the three-dot menu > Scan Library Files.
  • Optimize your media for streaming: To reduce buffering and improve playback, consider using Plex’s Optimize feature to create multiple versions of your media files optimized for different devices and network conditions. This can be found in the three-dot menu > Optimize.

Plex Customizations on Linux Mint

  • Customize your library: Personalize your library by adding custom posters, backgrounds, and descriptions. You can edit these by clicking on a media item, then clicking the Edit (pencil) icon.
  • Create playlists: Organize your favorite content into playlists for easy access and sharing with friends or family. To create a playlist, select the media items you want to add, click the three-dot menu > Add to Playlist.
  • Use Collections: Group related content, such as movies from a specific franchise, into collections. To create a collection, select the media items, click the three-dot menu > Add to Collection.
  • Customize Plex Web App appearance: Change the appearance of the Plex Web App by going to Settings > Web > General. Here, you can adjust the theme, language, and display options.

Other Plex Tips on Linux Mint

  • Enable subtitles: Plex can automatically download subtitles for your media files. Go to Settings > Agents > Movies or TV Shows and enable the OpenSubtitles.org agent.
  • Remote access: To access your Plex Media Server remotely, ensure that you have set up Remote Access correctly.
  • Backup your Plex metadata: Keep a backup of your Plex Media Server’s metadata to ensure you don’t lose your customizations in case of any issues. You can find the metadata folder at:
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/

Managing Plex Media Server on Linux Mint 21 or 20.

Update Plex Media Server on Linux Mint

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

Step 1: Check for updates

To check for updates, run the following command:

sudo apt update

Step 2: Upgrade Plex Media Server

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

sudo apt upgrade plexmediaserver -y

Remove (Uninstalling) Plex Media Server From Linux Mint

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

Step 1: Uninstall Plex Media Server

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

sudo apt remove plexmediaserver

Step 2: Disable Nginx reverse proxy (if applicable)

If you installed the Nginx reverse proxy, don’t forget to disable it and, if needed, 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: Installing Plex Media Server on Linux Mint

In conclusion, installing Plex Media Server on Linux Mint 21 or 20 is a straightforward process that enables you to enjoy a versatile and powerful media server platform. Following this guide’s installation and configuration steps, you can easily set up and optimize Plex for your needs. With a little effort in organizing your media library, customizing your settings, and following best practices, you can create a seamless and enjoyable experience for yourself and your friends or family. Always remember to keep your server up-to-date and follow the tips provided to maximize your Plex experience on Linux Mint.

Leave a Comment


Your Mastodon Instance
Share to...