The complete guide to installing, configuring, and managing Plex Media Server on an Ubuntu Server
Introduction
This guide covers how to install Plex Media Server (PMS) on a lower-powered Ubuntu Server. As a long-time Plex Pass user, I created a video titled HOWTO Setup a Plex Media Server (PMS) Appliance back in 2020.
While that computer (a laptop, actually) had been running flawlessly, I decided to replace it with a virtualised setup. As part of the upgrade process, I chose to start from the very beginning and document each action I performed. I also wanted to make this tutorial beginner-friendly, allowing anyone to follow along and replicate the steps I describe here.
What is Plex?
Plex is media server software that allows users to organise, stream, and share their personal media collections, including movies, TV shows, audio, and photos. Beyond streaming, Plex today also provides users access to channels (free and paid) and supports over-the-air hardware devices that allow users to route TV programming through Plex.
Besides media streaming, Plex offers players that connect to servers and allow users to manage content. The most obvious use is streaming, but users can also manage content directly. What makes Plex particularly useful is that their media players are available on many endpoints such as TVs, browsers, phone apps, and more.
One of Plex’s winning features lies in the fact that the product is stable, secure, and provides fine-grained access control to different people you grant access to your server. Another important consideration is that the interface is polished, stable, and intuitive—meaning anyone can figure it out without needing a technical degree to operate the product.
How I Use Plex
My media is split into two categories: watch ’n delete and keep-it. The names describe their lifespans. The watch ’n delete files are located on the PMS itself, and I delete them after consuming the content. On the other hand, keep-it files are stored on my NAS (with RAID and backups). These are personal media and special content I normally (optimistically) think I will watch many times!
My PMS is configured to pull content from both endpoints.
I also access PMS remotely when traveling, and my internet connection is occasionally low quality.
YouTube
I released a 14-part video how-to series to accompany this article. Each video is bite-sized and focuses on a single topic. This makes it easier to follow along and gives you the opportunity to skip steps that don’t apply to you (for example, if you’re not installing on Ubuntu Server).
The YouTube playlist is titled Plex on Ubuntu Server (Beginner-Friendly) and is available at: https://www.youtube.com/playlist?list=PLt_MXOexTCYUd6s5lOM0ZchYBHnGrpt-8.
Above each section, I’ll include the video covering that section.
Index
Step | Title | Applies to |
---|---|---|
1 | Install Ubuntu Server | Ubuntu/Plex |
2 | Install OpenSSH Server / PuTTY | Ubuntu |
3 | Install PMS on Ubuntu | Ubuntu/Plex |
4 | Setup SMTP on Ubuntu Server using Gmail as a Relay | Ubuntu |
5 | Generate an Email When Server Starts and Shuts Down | Ubuntu |
6 | Subscribe for Free to Ubuntu Pro | Ubuntu |
7 | Assign a Fixed IP to Server | Ubuntu |
8 | Setting Date and Time & Time Zone | Ubuntu |
9 | Configuring the PMS Folders | Ubuntu/Plex |
10 | Access Shares on Other Computers | Ubuntu/Plex |
11 | Create a RAM Disk for Fast, Temporary Processing | Ubuntu/Plex |
12 | Using Ubuntu’s Scheduler to Automate File Permissions | Ubuntu/Plex |
13 | Copy Media to the Plex Media Server | Plex |
14 | Adding PMS to your Account and Additional Tuning | Plex |
When Applies to is:
- Plex: indicates that this action directly relates to PMS
- Ubuntu/Plex: indicates that this is an action I perform on Ubuntu to support Plex. If you’re using a different OS, you need to do a similar action on that OS
- Ubuntu: means that this is an Ubuntu Server action I perform on my setup. You can skip it if you're only interested in Plex
Install Ubuntu Server
YouTube: https://youtu.be/pmsGeG2UJu0
The specifications of my original Ubuntu Server laptop were the following: - CPU: i5-6xxx series - RAM: 16GB - Storage: 500GB HD
My virtualised version is specced similarly.
Download the ISO for Ubuntu Server from https://ubuntu.com/server and boot your computer from it. Enter your credentials, accepting defaults on all other screens. Since my computer will only be used for Plex, I didn’t have a need to perform additional security measures such as encrypting the hard disk.
If you’re installing Ubuntu on a Virtual Machine, check whether that environment has any tools that enhance performance/functionality. With Proxmox, you should install and enable the QEMU Guest Agent, while on VMware Pro you should have open-vm-tools running (I cover the latter in the video).
Checking for Updates and Applying Them
Before installing any new software and periodically thereafter, you should check for package updates and apply them.
Plex alerts you that there is an update with a yellow arrow.
After you connect to the Ubuntu server, enter the following:
sudo apt update && sudo apt upgrade -y
You will be prompted to enter the root password you created during installation.
Editing Files
This tutorial requires that we edit certain files. Ubuntu comes with a number of text editors, and I use nano, which I consider the simplest. If you need a quick tutorial on how to use nano, leave a comment.
Elevated Privileges
In Linux, certain actions or accessing certain files require that you perform them using elevated privileges. To indicate that a command should assume this role, we use the command sudo. When you request such privileges, you’ll be asked to enter the root password. Such privileges remain in force for a period of time, meaning that subsequent sudo commands won’t prompt for the password each time.
Ubuntu on Proxmox : QEMU Guest Agent
On Linux, you simply need to install the qemu-guest-agent. Please refer to the documentation of your system.
For Ubuntu:
On Debian/Ubuntu-based systems run:
sudo apt install qemu-guest-agent
Ubuntu on VMWare Worklstation Pro
Install OpenSSH Server / PuTTY
YouTube: https://youtu.be/htlKpH8oalY
Server-Side
Being a server (physical or virtual), the computer normally sits in some corner where it lives quietly and is semi-forgotten. It simply does what it was designed to do without any hassle and very little attention. Also, Ubuntu Server doesn’t have a GUI (making it very efficient). This means that some actions are much easier to accomplish if you have a GUI companion computer to perform certain tasks. In our tutorial, we simply copy text from one computer to another, considerably simplifying the complexity of setting up the PMS server.
One normally tends to access servers remotely from other devices on the network. The widely-used OpenSSH server implementation provides a robust and encrypted method for managing systems remotely.
During installation, you’re asked whether you would like to install OpenSSH. If you chose yes, you can skip this step. To check if OpenSSH server is running, enter the following:
systemctl status ssh.service
If it’s not installed, you can install it by executing:
sudo apt install openssh-server
Checking the status again should list it as enabled, waiting for a connection.
Client-Side
Having configured the server side, we now need a client. There are many free clients available for different operating systems (Linux, Windows, Mac, Android, and iOS). In this tutorial, I access the server from Windows using PuTTY. Perform a search if you’re on a different OS or prefer an alternative to PuTTY.
The first time you establish a connection, you’ll be prompted to validate the connection and exchange the keys between the client and server.
Install PMS on Ubuntu
YouTube: https://youtu.be/9yvzFfjkGq0
The URL for Linux PMS downloads is https://www.plex.tv/en-gb/media-server-downloads/?cat=computer&plat=linux#plex-media-server.
Right-click on the distribution that applies to you (in this tutorial it is Ubuntu … Intel/AMD 64-bit) and choose the option to copy the link.
We use the curl command to download the package to a temporary file called pms.deb in the /tmp folder, after which we install it.
curl-o /tmp/pms.deb https://downloads.plex.tv/plex-media-server-new/1.41.7.9823-59f304c16/debian/plexmediaserver_1.41.7.9823-59f304c16_amd64.deb sudo apt install /tmp/pms.deb
After installation, we can check whether Plex was installed by checking the status.
systemctl status plexmediaserver.service
By default, Plex doesn’t check for updates (a wrong appliance mentality that should change in today’s cyber world). To address this shortcoming, edit the file /etc/apt/sources.list.d/plexmediaserver.list, uncommenting a line as directed in the file itself.
sudo nano /etc/apt/sources.list.d/plexmediaserver.list
Setup SMTP on Ubuntu Server using Gmail as a Relay
YouTube: https://youtu.be/pzvzvG7M774
As stated, the PMS is a setup-and-almost-forget device. If something goes wrong, you may not necessarily realize that an event took place. Here we go over how to set up the Ubuntu server so that it can send out notifications as emails. We will use Gmail to send out emails.
Install Postfix
We first need to install postfix. When asked to select the configuration, you can choose any option since this will be changed later on.
sudo apt install -y postfix libsasl2-modules mailutils
Create App Password on Google
Head over to https://accounts.google.com, sign in, and search for App passwords. Enter an appropriate name that will help you recall where you used the password 5 years later and copy the generated password into a text editor, deleting any spaces.
Edit the postfix configuration file:
sudo nano /etc/postfix/main.cf
Clear out the content and replace with the following:
# Use Gmail as relay relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_use_tls = yes
Create the file that will store your credentials:
sudo nano /etc/postfix/sasl_passwd
Enter the text below (replacing your email and generated app password):
[smtp.gmail.com]:587<your gmail email>:<your gmail app password>
Secure the file, making it accessible only to root:
sudo chmod 600 /etc/postfix/sasl_passwd
Create a hashed database file from the credentials file:
sudo postmap hash:/etc/postfix/sasl_passwd
Restart the postfix service and verify that it is active:
sudo systemctl reload postfix systemctl status postfix
Send a test email:
echo "This is a test email." | mail -s "PMS Test email" <recipient_email_addr>
Generate an Email When Server Starts and Shuts Down
YouTube: https://youtu.be/Hb0DHaDKdRg
Here we send an email on server startup and shutdown. Other use cases in which you might want to be email-alerted are power notifications from your UPS software or if you’re running low on disk space. Don’t go email-happy as, over time, too many emails risk you simply ignoring everything from your PMS.
Create the Email Script
Create a script (/usr/bin/bootmail.sh) that will send the startup and shutdown emails. The action will be passed as a parameter ($1). You may add additional environment variables if you so desire.
sudo nano /usr/bin/bootmail.sh
Enter a script similar to the one below (change the recipient email):
#!/bin/sh SUBJECT="PMS HOST $1" echo"For information purposes"|mail-s"${SUBJECT}"<recipient_email_addr>
Make it executable and readable only by root:
sudo chmod 700 /usr/bin/bootmail.sh
Create the Server Start/Stop Service
Create a service that will be executed when the OS starts and stops. The service will invoke the script created above with the appropriate parameter.
sudo nano /etc/systemd/system/bootmail.service
Type in the following code:
[Unit] Description=Bootmail Service - Sends email on boot and shutdown
# Ensures network is up before attempting to run After=network-online.target Wants=network-online.target
[Service] # This type is suitable for scripts that run once and exit Type=oneshot
ExecStart=/usr/bin/bootmail.sh startup ExecStop=/usr/bin/bootmail.sh shutdown
# Keeps the service marked as "active" even after ExecStart exits RemainAfterExit=yes
[Install] # Ensures the service starts when the system reaches multi-user state WantedBy=multi-user.target
Install the service and verify that it is active:
sudo chmod 700 /etc/systemd/system/bootmail.service
sudo systemctl daemon-reload sudo systemctl enable bootmail.service systemctl status bootmail.service
Test the Service
Restart your server and check your email client. You may notice that the email to inform you of the server shutdown doesn’t get sent in a timely manner. This is because the service is invoked after the network goes down.
If anyone has a solution, please share it.
Subscribe for Free to Ubuntu Pro
YouTube: https://youtu.be/gqTukHrlWJs
Ubuntu Pro registration offers significant benefits, especially for personal users and small businesses, extending beyond the standard Ubuntu LTS support. For a PMS server in a home environment, the two most important benefits are Extended Security Maintenance and Live Kernel Patching.
Go to https://ubuntu.com/pro and login or register. You will have a token that you can apply to 5 of your Ubuntu machines.
sudo pro attach <Token>
Assign a Fixed IP to Server
YouTube: https://youtu.be/6OKA9UxqEcQ
Having a fixed IP on a server ensures that its IP address will not change. This is important when you need to access the server from other devices or have routing information that directs packets to/from it.
During installation, you can set the server’s IP address. This method describes how to do it afterwards.
You normally require the IP address, the DNS server, and the gateway. If you’re not sure what they are, you should get them before. Search for the command nmcli for more information.
You also need the adapter name. You get this using the command:
ip addr show
Armed with this information, list the contents of the directory /etc/netplan/
and edit the YAML file contained within:
sudo nano /etc/netplan/<name of yaml file>
Replace the contents of the file with details similar to the one shown here:
network: version:2 ethernets: ens18: # must match your adapter name dhcp4: no addresses: - <fixed ip>/<CIDR> # must match your network routes: - to: 0.0.0.0/0 via: <gateway> # must match your network nameservers: addresses: - <DNS> # must match your DNS
YAML is strict about spaces and tabulation. You can check the YAML file by using:
sudo netplan try
Then, if all is well, you can apply the new network configuration using:
sudo netplan apply
Once the IP address of the server changes, your connection will fail and you need to connect again.
Assigning an IP by your Router
While the method described above is the preferred method, you may want to look up how you can get your router to assign the same IP address by tying the computer’s MAC address to the IP. The computer’s MAC address is shown when you execute ip addr show
.
The problem with this method is that if the router is replaced and the MAC address table is not transferred, the server will lose its fixed IP and you would need to set it again.
Setting Date and Time & Time Zone
YouTube: https://youtu.be/VWx0DAWPecU
If for some reason there were not automatically detected.
date
sudo date --set"26 May 2025 15:31:00" timedatectl list-timezones sudo timedatectl set-timezone "Europe/Malta"
Configuring the PMS Folders
YouTube: https://youtu.be/XHCi1xso-Zw
The assumption in this guide is that all the PMS media files will be located under a folder called /plexmedialibrary. Furthermore, this setup assumes that the media will fall under one of the following categories:
- TV series
- Movies
- Other (media that doesn’t fall in the above two categories)
Create the folders and adjust the access permissions to give everyone read and write access to the folders. These file permissions allow you to delete media through the Plex app. If you don’t want to be able to delete media, remove the w(rite) attribute.
sudo mkdir /plexmedialibrary cd /plexmedialibrary
sudo mkdir movies &&sudo mkdir other &&sudo mkdir tv
# make these folders accessible to everyone sudo chmod ugo+rw /plexmedialibrary sudo chmod ugo+rw /plexmedialibrary/other sudo chmod ugo+rw /plexmedialibrary/movies sudo chmod ugo+rw /plexmedialibrary/tv
Plex also works with photo and music files. You may further subdivide a collection—for example, having holiday media separate from media you consume during the rest of the year. If this is your case, you can create additional folders to meet your needs.
Access Shares on Other Computers
YouTube: https://youtu.be/zgK0k7uNYwA
Besides placing media on the Plex Media Server itself, you may have media on other devices. My use case is to place media I want to keep permanently on a NAS device (that has redundancy and is backed up) while placing media I will watch and delete on the PMS server itself.
The assumption is that you have created a network share on the remote computer with a username and password.
On PMS, install CIFS (Common Internet File System) module:
sudo apt install cifs-utils
Create the mount folders that will be associated with the share. It is common practice to place these under the /mnt (mount) folder:
sudo mkdir /mnt/pms-photos
Create the file that will hold the share credentials:
sudo nano /etc/win-credentials
Enter the following information:
username=<username> password=<password>
Allow only root access to the file:
sudo chmod 600 /etc/win-credentials
fstab is a configuration file that defines how and where disk partitions, storage devices, and remote filesystems should be automatically mounted at boot time. We will create the mount point for this network share.
sudo nano /etc/fstab
Move to the end of the file and add the line for your share. Enter the IP address and share name for your device. Spaces in share names need to be replaced by \040
.
//<<ip address>>/<<sharename>> /mnt/pms-photos cifs credentials=/etc/win-credentials,uid=1000,gid=1000
After saving the file, reload fstab:
sudo mount -av
When specifying the remote computer, we used its IP address. As discussed, if the device IP changes, the share will no longer be available and the fstab file will need to be adjusted. Alternatively, you can access a network share by computer name instead of using its IP address, but this varies depending on the OS. If you would like a how-to on this topic, leave a comment.
Create a RAM Disk for Fast, Temporary Processing
YouTube: https://youtu.be/963F5HOIVaE
PMS makes use of temporary files in the /tmp folder. Having a RAM disk for handling temporary files improves performance and reduces wear and tear on the hard disk. In this step, we set aside memory as a RAM disk.
By default, the /tmp directory, and its size limit is set to 50% of the total physical RAM.
One can operate PMS on Ubuntu Server on a machine with 4GB of RAM, although 8GB is the recommended amount, providing headroom for multiple transcodes and running of additional services. Anything above that could be transformed into a RAM disk. In this example, the server has 16GB of RAM, meaning that the RAM disk will be set to 8GB.
As we did before, we edit the fstab file:
sudo nano /etc/fstab
And add the following line to the end:
tmpfs /tmp tmpfs rw,size=8g 0 0
After saving the file, we mount the file systems:
sudo mount -av
To display the /tmp entry, use:
df -h /tmp
Using Ubuntu’s Scheduler to Automate File Permissions
YouTube: https://youtu.be/3NV–V6Fa4s
The use case presented here is one in which media files in the /plexmedialibrary folder tree can be deleted from Plex’s interface. To do this, we need to ensure that folders and files are read-write. The command to change file permissions has been discussed earlier and is:
chmod -R a+rw /plexmedialibrary
This recursively changes the permissions of all files and directories under /plexmedialibrary
so that all users (a) have read and write (rw) permissions. In the earlier example, we used ugo (user, group, others) instead of a (all)—they are identical.
Linux has a time-based job scheduler called cron which allows you to automate repetitive tasks by scheduling them to run periodically at fixed times, dates, or intervals. These scheduled tasks are often referred to as cron jobs.
There is a crontab generator at https://crontab-generator.org/ that automates the process of creating a task. In our case, we want to run the command every 30 minutes. On the page, we set the frequency, paste the command, and press the Generate Code button.
The tool will generate the command that you will need to paste into the scheduler tool. Based on the settings above, it is:
*/30**** chmod -R a+rw /plexmedialibrary >/dev/null 2>&1
Open the scheduler and paste the line at the end of the file. The first time, you will be asked to choose the editor:
sudo crontab -e
Copy Media to the Plex Media Server
YouTube: https://youtu.be/iSovPnbwLZc
Here we go over how to transfer media to your PMS media folders, which in our case is /plexmedialibrary.
Our assumption is that the media resides on another computer and therefore needs to be transferred. The utility we use is scp (secure copy), a command-line utility in Linux that allows you to securely copy files and directories. In Windows, we use the command pscp, which is part of the free and open-source PuTTY Suite (https://www.putty.org/). The syntax is identical.
[Linux] scp -r[source] [remote account]@[pms server ip]:[pms path] [Windows] pscp -r[source] [remote account]@[pms server ip]:[pms path]
Assuming you want to recursively copy all folders and files from /<localfolder>
to the folder /plexmedialibrary/tv on the PMS server having IP address <ip address>
and the login account on the PMS server is <login acc>
, the syntax (Linux) would be:
scp -r /<localfolder>/* <login acc>@<ip address>:/plexmedialibrary/tv
You will be prompted to enter the password for <login acc>
.
Adding PMS to your Account and Additional Tuning
YouTube: https://youtu.be/XLMJmpZ7QXs
Adding the Server to your Account
Log into https://app.plex.tv/ and follow that with the URL of your new server:
https://<ip address>:32400/web
You will get a certificate error which you need to accept. Afterwards you will be prompted that server is not hosted by Plex.
After the above, you will be asked to give your server a friendly name (it defaults to the server name) and whether you would like to access media from outside your house.
The next stage of the Server Setup is to organise your media.
Here you will associate the local and network shares you defined earlier with the type of content they hold.
Plex will then start indexing the content. With large collections, the process may take some time.
Additional Configurations
Additional configurations to the PMS are done through the Settings menu that you can access by clicking the wrench icon on the top right of the Plex interface.
Remote Access
For remote access, you must enable access to your PMS from the internet. The default port is 32400. You will need to configure your router to allow inbound traffic on this port. You should also configure your PMS to set the maximum stream bitrate. If you would like more information on this, leave a comment.
Transcoder
The Transcoder option is where PMS will convert videos in real time when streaming to Plex apps. One of the options in this section is the Transcoder temporary directory. Here we will enter the path to the RAM disk, /tmp.
Other settings allow you to fine-tune the transcoder options.
Comments, Questions and Observations
If you have any comments—be they how you configure your PMS, questions about any part of this how-to, or observations—please leave a comment.
Comments
Post a Comment