Install Plex Media Server on Ubuntu

Install (for ubuntu)

It's Back! After a long abscence the repo has returned

echo deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl | sudo apt-key add -

sudo apt-get update
sudo apt-get install plexmediaserver

You may wish to relocate the library database for space or security reasons

sudo service stop plexmediaserver
sudo mv 
/var/lib/plexmediaserver /mnt/crypt
sudo ln -s /mnt/crypt/plexmediaserver 
sudo chown plex:plex 

You may also need to adjust the range of IPs allowed in without Auth for initial setup

sudo vim "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"

... allowedNetworks="" ...

Allow Firewall Access

sudo vim /etc/ufw/applications.d/plexmediaserver

title=Plex Media Server
description=Plex Media Server is the back-end media server component of Plex

# Add custom rules as needed
sudo ufw allow from to any app plexmediaserver
sudo ufw deny from to any app plexmediaserver
sudo ufw allow plexmediaserver

Setup Command Line Control

You can kick off scans via the command line, but you have to invoke the commands as the plex user.


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 "%Doctor Who 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


JOIN media_parts JOIN media_items

    media_parts.file LIKE "%Doctor Who E07E01.mkv%";


curl http://localhost:32400

http://<server name>:32400/web


cd /var/lib
tar -czf ~/plexmediaserver.tgz plexmediaserver


sudo vim /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml 

tail -20 /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Logs/Plex\ Media\ Server.log

apt update gives the warning:

W: Conflicting distribution: public InRelease (expected public but got )

From Plex

Yes, There is a warning. Ignore it.
There are two different requirements for the layout based on the distro itself (Debian vs Ubuntu).
We ended up with a compromise which works except for Ubuntu 17 and that warning.

Database info