Ubuntu 16.04: Install PLEX for personal media server like youtube

This article will describe installing PLEX and run media server for private net work without PLEX registration.

IP address of Ubuntu 16.04 is 192.168.11.86.

 

1 Install PLEX

Download latest PLEX from project page.

$ wget https://downloads.plex.tv/plex-media-server/0.9.16.6.1993-5089475/plexmediaserver_0.9.16.6.1993-5089475_amd64.deb
$ sudo dpkg -i plexmediaserver_0.9.16.6.1993-5089475_amd64.deb

A systemd is set and plex user is added when installing PLEX. If you use ufw, open 32400/tcp and 32400/udp.

2 Install Chromium

Firefox cannot play movie of PLEX. Please install Chrome or Chromium.

$ sudo apt-get install -y chromium-browser chromium-browser-l10n

3 Connect to PLEX

Access to below URL with Chromium or Chrome.

http://[IP address or name of Ubuntu 16.04]:32400/web

License agreement is dislayed. Press "Agree".

0001_License_en.png

Access to URL again.

4 Add Library

PLEX manages movies and pictures with Library.

Library will scan all file recursively from the specified directory and create metadata like thumbnail.

And then movie and picture is available.

The metadata is at below direcotry.

/var/lib/plexmediaserver/Library/Application\ Support

Movie library will scan only movie data and Picture library will scan only picture data.

This article will use Movie library specified with below directory.

/var/lib/plexmediaserver/Library/Movies

Press "Add Library" at the left side and choose. Select library type and press "NEXT".

0002_Add-Library_en.png

Press "BROWSE FOR MEDIA FOLDER".

0003_Select-Directory_en.png

Specify directory of library.

You can specify multiple directory.

Press "ADD" and "ADD LIBRARY".

0004_Input-Directory_en.png

You should create directory if the directory is not exists.

The directory must be readable by PLEX.

$ sudo mkdir -p /var/lib/plexmediaserver/Library/Movies
$ sudo chown hiroom2:hiroom2 /var/lib/plexmediaserver/Library/Movies
$ ls -l /var/lib/plexmediaserver/Library/
total 8
drwxr-xr-x 3 plex    plex    4096  5月 21 23:24 Application Support
drwxr-xr-x 2 hiroom2 hiroom2 4096  5月 22 12:36 Movies

5 Add movie

There is no way of uploading movie and picture by browser.

You need to move movie and picture to direcotry.

This article will run mv command.

MyYoutube is a directory which includes multiple movies.

$ mv MyYoutube /var/lib/plexmediaserver/Library/Movies/

Scan will not be started automatically by default.

You can start to scan manually by pressing "Update Library".

0005_Manual-Scan_en.png

Deck shows thumbnails of movies after scanning.

0006_Complete-Scan_en.png

Movie will be started by clicking a thumbnail.

0007_Play-Movie_en.png

6 Allow access only from private network

PLEX can control access list with IP address. Press "Setting".

0008_Config_en.png

Press "Server" at the upper right. Press "Network" and "SHOW ADVANCED".

0009_Config-Server-Netowrk_en.png

Add access list to "List of networks that are allowed without auth".

This article will add private network "192.168.11.0/255.255.255.0".

Press "SAVE CHANGES" and setting will be updated.

0010_Network-List_en.png

If you use apache2 digest authentication, please add "127.0.0.1/255.255.255.255".

7 Scan automatically

Scan is not started automatically by default.

This article will change to be started automatically when the directory of library detectes changes.

Press "Library" at "Setting".

Check "Update my library automatically".

Press "SAVE CHANGES" and setting will be updated.

0011_Auto-Scan_en.png

8 Apache2 digest authentication (Optional)

PLEX does not have an authentication for private network.

This article will use apache2 proxy_http module and enable authentication for private network with auth_digest module.

There is a room for changing URL like www.my.server to www.my.server/plexmediaserver.

 

Install apache2 with apt and enable modules with a2enmod.

$ sudo apt-get install -y apache2
$ sudo a2enmod proxy_http rewrite auth_digest

Create password file which has a realm "plexmediaplayer" realm and a user "hiroom2".

This user will be used when accessing to URL.

$ sudo htdigest -c /etc/apache2/.plexmediaserver_htdigest "plexmediaserver" hiroom2
Adding password for plexmediaserver in realm hoge.
New password:
Re-type new password:

Create site configuration for PLEX according to this site.

$ cat /etc/apache2/sites-available/plexmediaserver.conf
ProxyPass         / http://127.0.0.1:32400/
ProxyPassReverse  / http://127.0.0.1:32400/
ProxyRequests     Off
ProxyPreserveHost On

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteRule ^/$ /web/$1 [R,L]

<Proxy http://127.0.0.1:32400>
  AuthType Digest
  AuthName "plexmediaserver"
  AuthUserFile /etc/apache2/.plexmediaserver_htdigest
  Require valid-user
</Proxy>

Enable site with a2ensite.

$ sudo a2ensite plexmediaserver

Restart apache2.

$ sudo systemctl restart apache2

You can still access with :32400.

Please change "List of networks that are allowed without auth" to "127.0.0.1/255.255.255.255".

0014_NoAuth-LocalHost-Only_en.png

Username and password are required when access to URL without :32400 on Chrome of Android.

0012_Digest-Auth_en.png

Accessing to PLEX is completed.

0013_Plex-from-Android_en.png