Plex is a media streaming application that allows you to keep your media collection – movies, music, photos – on a server attached to your local network and access them from a browser-based interface or app. Plex even streams a wide variety of podcasts and shows directly from the internet and by upgrading to the Premium (paid) tier Plex offers many more services. You can use the free version of Plex if you only want to view your own media and free to view streaming content.
In this guide, we will install Plex on a Raspberry PI minicomputer. Raspberry PI’s make grade Plex streaming servers because:
They are low power and fan-less. You can leave them running 24/7 without worrying about your energy bills.
They are sufficiently powerful to stream HD movies to your computer.
They are full computers with a desktop environment so you can log and use GUI tools to manage them.
They are $35 USD!
These reasons make a Raspberry PI an ideal home streaming server and a great introduction to using Linux if you haven’t already taken the plunge.
You will need a few things to get your Plex server up and running. They are as follows:
Raspberry PI 3 (any version).
16GB microSD card.
Micro-USB Android phone charger (for the Raspberry PI).
HDMI monitor or TV to use a monitor.
USB storage device which is large enough to hold your media.
A Plex user account (optional). You will need to this to claim your Plex media server and lock it to your account with your user name and password. You can register a Plex user account (for free) at https://www.plex.tv/
You will use the keyboard and mouse to access the Raspberry PI during the installation and configuration. You will not need them later during normal use of Plex as we will configure the Raspberry PI be accessible via a VNC remote desktop connection.
Installing The Operating System
Your first job is to get the operating installed onto the microSD card that will hold the OS of the Raspberry PI. The operating system that we will install is Raspbian . Raspbian is based on the Debian operating system and compiled for the ARM CPU that the Raspbian uses.
Browse to the download page here and download the Raspbian Stretch with desktop image. This is a large, 1.1GB, file that you need to save to your computer. Do not unzip this file. The software we will use to flash it to the microSD card will do this for you.
If you are an experienced Linux user the command line instructions for flashing the Raspbian image are here
Everyone else needs to download and install the software that we will use to flash the microSD card – balenaEtcher . This software is a beautiful cross-platform (Windows, OSX, and Linux) application that flashes SD cards and USB thumb drives.
Note, you will erase any data on the microSD card in the next step so make sure you have a copy of any data on it before you proceed.
Insert your microSD card into your computer and start up balenaEtcher. The simple screen that you will see looks like this:
Click on the Select image button and browse to the Raspbian image you downloaded and select it. balenaEtcher will search for and automatically select the microSD card that plugged into your computer. Check that the size listed next to the device that balenaEtcher has selected is the same size as your micoSD card just to be sure you are using the right device.
When you are ready hit Flash! . It will take several minutes to flash the microSD card. When balenEtcher has finished remove the microSD card and load it into your Raspberry PI.
Plug the screen and keyboard into your Raspberry PI and then plug in the phone charger. The Raspberry PI will now power on. Log in with the following details:
Username – pi
Password – raspberry
Follow the first-boot, on-screen instructions until you get to the desktop.
You will need to open a terminal to continue the guide.
System Users and Groups
When you install Plex later in this guide a new system user will be created called plex . We are going to create this user now so that we can use it before we install Plex.
In the terminal you have open on the Raspberry PI run the following command to create the new user called plex :
sudo useradd plex
This command will not create a home directory at /home/plex it will only add the user to the system. Now that plex exists we are going to add them to the users group. This will allow us to mount the USB storage device using the users group which will allow both plex and pi to read and write to the device.
The following command will add plex to the users group:
sudo usermod -a -G users plex
Auto-Mounting The USB Device
Raspbian will always give the device name /dev/sda to the first USB device that you plug into the Raspberry PI. This allows us to create an entry in the file that configures device mounting, /etc/fstab , so that the USB you have your media on will always get automatically mounted at the same location.
Before you edit /etc/fstab you need to get the UID ( U ser ID ) of pi and the GID ( G roup ID ) of users . First, get the UID of pi by running this command:
sudo grep "pi" /etc/passwd
This will give output that looks like the following:
pi ‘s UID is the first number i.e. 1000. The following command will get the UID of users :
sudo grep "users" /etc/group
This prints the output:
The UID of users is 100. Using this information open /etc/fstab with a text editor. Here nano is used:
sudo nano /etc/fstab
Add a line that has the following format:
/dev/sda1 /media/pi/Media vfat umask=0002,gid=<GID>,uid=<UID> 0 0
Substituting the values we discovered earlier:
/dev/sda1 /media/pi/Media vfat umask=0002,gid=100,uid=1000 0 0
You must use the values from your Raspberry PI.
Finally, we need to create the directory we have set as the mount point and change its user and group:
sudo mkdir -p /media/pi/Media
sudo chown -R pi:users /media/pi
sudo chmod -R 775 /media/pi
Plug in your USB device and confirm that it has been automatically mounted at /media/pi/Media . You will be prompted to open a file manager when you plug in the USB device that will open to its mount point i.e. /media/pi/Media .
Plex is not installable from the default Raspbian repositories. As a result, you will need to add the Plex repository and their APT signing key.
Add their APT key with the following command:
sudo wget https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add -
Next, open a new APT sources file that will contain the address of the Plex repository:
sudo nano /etc/apt/sources.list.d/plex.list
Add this line:
deb https://downloads.plex.tv/repo/deb public main
Save and exit. Before installing new software a good policy is to first perform a system update. This will help avoid any installation errors. Run these two commands to get your Raspberry PI up to date:
sudo apt update
sudo apt upgrade
When they have completed install Plex with this command:
sudo apt install plexmediaserver
Plex is now installed and ready to start serving media. You should, if you haven’t already done so, plug in your USB device that contains your media now.
Logging into Plex
Plex is now running and listening on the public IP address of the Raspberry PI. You will need to get the IP of the Raspberry PI so that you can log into Plex. In the terminal you have open run this command:
The IPv4 IP address will be the first one listed. Take this IP address and create a URL that has the same format as the following one:
Substituting <IP> with an example private network IP gives us the example URL:
Enter that into a browser on your computer on the same local network as your Raspberry PI.
Here, if you have signed up for a Plex account, you need to use those credentials to log into your Plex server. The Plex server will verify the user name and password with the Plex servers. You do not need to do this but not doing so will disable functionality including some security features.
Adding Your Media Library
During the initial login and setup you will be prompted to add your own media library with the following dialog:
You can also do this from the Plex desktop after the initial setup by clicking on the Add Library link in the side navigation panel.
When you click “Add Library” dialog box will open:
Choose the type of media on your USB device and change the name of the library by clicking on the Name field. Then click Next .
Now click on the BROWSE FOR MEDIA FOLDERS button on the page that follows:
This will open a new dialog:
Select the Media folder and click ADD . This is the folder we created to mount your USB cevice e.g. /media/pi/Media . Finally, confirm that this is correct by clicking the ADD LIBRARY button. All your media on the USB device will now appear on the Plex desktop and be ready to stream to any device on your local network.
Enabling The VNC Remote Desktop
VNC is an open source version of the Windows Remote Desktop Protocol. It enables a person to log into the desktop environment of a remote computer such as your Raspberry PI. When you have enabled VNC you will not have to use a keyboard and mouse to access your Raspberry PI’s desktop.
The default Raspbian image contains all the VNC components so you don’t need to install anything but you do need to enable it.
Open a terminal on the Raspbian desktop and enter the following command:
This will open a command line menu. Use the up and down arrows and enter to navigate the menus. Proceed as follows:
Highlight Interfacing Options and hit enter.
Highlight P3 VNC and hit enter.
Hit enter for <Yes> .
Confirm <OK> .
Use the TAB key to highlight <Finish> and hit enter to exit the program.
You can now log into your Raspberry PI desktop using the VNC Viewer . Downland and install this application on your local computer and use the IP address of your Raspberry PI to log in as the pi user.
Adding New Media To Your Library
When you need to update the media on your USB device so that you have new movies or shows to watch there are two ways to get this done.
Moving The USB Device
The first method is to unplug the USB device from your Raspberry PI, plug it into your local computer, copy the data onto it and move it back.
The following procedure will ensure that you do not corrupt the data on the USB device.
Log into your Raspberry PI’s desktop via the VNC Viewer application linked to in the Enabling The VNC Remote Desktop section.
Shutdown the Raspberry PI.
Unplug the USB.
Plug the USB device into your local computer.
Copy your data on the device.
Eject or unmount the USB device.
Unplug the USB device.
Plug the USB device into the Raspberry PI.
Unplug and plug back in the power cable to the Raspberry PI.
When your Raspberry PI boots up log back into Plex click on the three dots next to your Media Library then click on Scan Library Files . This will prompt Plex to review the contents of the USB device and add the new media files to your Library.
Copying Files Over The Network
Your Raspberry PI is connected to the local network so you can transfer your media to it over the network instead of manually moving the USB to your computer to copy the files.
The best program to get files securely from your Windows computer to the Raspberry PI is called WinSCP . Follow that link to download, install and open WinSCP.
WinSCP will open the following dialoge box:
Fill in the boxes as follows:
Host – Enter the IP of your Raspberry PI.
Username – Enter pi .
Password – Enter the password for user pi .
Click Save and create a bookmark for the Raspberry PI. Finally, hit Login to log into your Raspberry PI.
Use the address bar in the right-hand panel to navigate to /media/pi/Media :
You can create directories to organize your media in there and the Plex server will automatically index everything.
Accessing Your Media
In this guide, you have accessed your Plex with a browser from your local computer. You are also able to access your Plex server from your phone or tablet via the official Plex app. This link will install if for Android . If you are using an iPhone or an iPad search for “Plex” in the AppStore on your device.
You have now got a Raspberry PI installed and running as your Plex media server on your local home network. This article covered the basic installation and configuration to get a Plex up and running. Now that you have done that you should read some of the articles on the Plex website that cover how to get the most of your Plex server: https://support.plex.tv/articles/ .
The post How To Install and Use A Plex Media Server On Raspbian Stretch appeared first on Low End Box .