Plex
Plex is the preeminent personal media server. While they’ve locked some features behind a subscription and are branching out into cloud providers, it remains a solid choice. They have clients for a lot of different Tablets and TVs, and importantly make connecting your family to your home videos easy.
Installation
Plex has jumped on the pipe-to-shell installation method and you can now run this to install.
curl -LsSf https://repo.plex.tv/scripts/setupRepo.sh | sudo bash
This sets up the repo and installation you’d have done manually in the past.
Configuration
Unattended Upgrades
To allow unattended updates of plex, install the unattended upgrade package and a site to the Origins-Pattern section.
Note: The Plex installer may be doing this already at this point, but I’ve left this hear just in case.
sudo apt -y install unattended-upgrades
sudo vi /etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Origins-Pattern {
...
...
"site=downloads.plex.tv";
};
Authorized IPs
Most private ranges are automatically granted access, but you may need to adjust.
sudo vim "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"
... allowedNetworks="192.168.1.0/24" ...
Metadata Library
The metadata library can get very large. Many tens of gigabytes in some cases. So you may wish to relocate it for space or even security reasons.
sudo service stop plexmediaserver
sudo mv /var/lib/plexmediaserver /mnt/crypt
sudo ln -s /mnt/crypt/plexmediaserver /var/lib/plexmediaserver
sudo chown plex:plex /var/lib/plexmediaserver
Firewall Access
If you’re using Ubuntu and have UFW running, adjust as below.
sudo vim /etc/ufw/applications.d/plexmediaserver
[plexmediaserver]
title=Plex Media Server
description=Plex Media Server is the back-end media server component of Plex
ports=32400/tcp
# Add custom rules as needed
sudo ufw allow from xxx.xxx.xx.0/23 to any app plexmediaserver
sudo ufw deny from xxx.xxx.0.0/16 to any app plexmediaserver
sudo ufw allow plexmediaserver
Hardware Transcoding
Operation
Command Line Control
You can kick off scans via the command line, but you have to invoke the commands as the plex user.
#!/bin/bash
sudo su -c "export LD_LIBRARY_PATH=/usr/lib/plexmediaserver;/usr/lib/plexmediaserver/Plex\ Media\ Scanner --scan" plex
You can also just become the plex user, of course, if it’s not too awkward
sudo -i -u plex
/usr/lib/plexmediaserver/Plex\ Media\ Scanner --list --section 1
Searching for mis-matches in the DB
When you have a large collection, it becomes almost impossible to find where some items land at. You can however, search the database
sudo apt install sqllite3
sqlite3 "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db"
select media_item_id,file from media_parts where file like "%Kid Party E07E01.mkv%";
select metadata_item_id,hints from media_items where id=1011881;
select title from metadata_items where id=173491;
Or for a complex join
SELECT
metadata_items.title,media_parts.file
FROM
metadata_items
JOIN media_parts JOIN media_items
WHERE
metadata_items.library_section_id=1
AND
metadata_items.id=media_items.metadata_item_id
AND
media_items.id=media_parts.media_item_id
AND
media_parts.file LIKE "%Kid Party E07E01.mkv%";
Checking the Logs
tail -f /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs/Plex\ Media\ Server.log
Sources
Database info: https://forums.plex.tv/t/howto-query-data-from-plex-on-a-mac/11636
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.