The Raspberry Pi is a very capable little device that can do all sorts of things. One cool thing is being able to turn it into a Raspberry Pi Plex Media Server. Plex is a media player that organizes all of your TV Shows, Movies, Music, and Pictures. The Plex server will allow you to transmit all of your media to a client, which can be pretty much any device (eg. PS4, Xbox, Smart TV, Tablet, Phone, etc). You don’t even necessarily need to be connected to your home network to access your media, you can be anywhere in the world.
The Raspberry Pi is a very ideal way to host a Plex Media Server. Not only is it an inexpensive Linux computer (about $35) but it has very low power consumption. A typical laptop uses 60 watts per hour, the Raspberry Pi uses 1.4 watts per hour. A media server is meant to be on most of the time, so minimizing power consumption is important.
The Ideal Setup
Which model of the Raspberry Pi should I use?
A Raspberry Pi 3 or 2 will work best. I do not recommend using the original Raspberry Pi since the components are outdated and the server may run sluggishly.
Caveats: Running a Plex server on a Raspberry Pi limits your streaming to 1080p. You will not be able to stream 4K movies due to the Raspberry Pi’s limited power. If this is an issue I would suggest looking into the more powerful ASUS Tinker Board.
Where to store your media files?
The best place to store your media files would be a Network Attached Storage (NAS). This could be in the form of a traditional NAS like “WD My Cloud” or similar, or simply an external HDD connected via the USB port of your router.
Though less ideal/convenient, you could also place your files on your Raspberry Pi’s micro SD card or connect an external HDD to your Raspberry Pi. These are less ideal than a NAS because video files are large, and large micro SD cards are expensive. Although Pi Ethernet speeds are limited to 100Mbps, and USB 2.0 transfer speeds are higher, the convenience of a NAS outweighs this for me.
Update: You can check out Jeff Geerling’s post for information and benchmarks on adding a Gigabit adapter to your Pi to increase Ethernet speeds.
Requirements
- Raspberry Pi 3 Kit
- 8GB microSD Card for Raspberry Pi OS
- Storage for media files (the bigger the better)
- External HDD (recommended)
- Traditional NAS
Instructions
1. Install Raspbian OS
First, you must install the Raspbian OS on your Raspberry Pi. Check out the official guide here.
2. Install the Raspberry Pi Plex Server
We will need to make sure that our Raspberry Pi software is up to date before we proceed to install Plex. Log into your Raspberry Pi, open up a terminal window and type the following commands:
1 2 |
sudo apt-get update sudo apt-get upgrade |
This can take a while if you are running a fresh install of Raspbian or if you haven’t updated your packages in a while.
Once that is done, we will install the “apt-transport-https” package since we will be downloading the Plex Server from an unofficial source that has an https address.
1 |
sudo apt-get install apt-transport-https |
Next, we will download a secure key that will authenticate our downloads from Dev2Day (source where we are downloading from). Dev2Day has compiled the Plex Server for the Raspberry Pi.
1 |
wget -O - https://dev2day.de/pms/dev2day-pms.gpg.key | sudo apt-key add - |
After that has downloaded, we will add the Dev2Day repository to our Raspberry Pi source list.
1 |
echo "deb https://dev2day.de/pms/ jessie main" | sudo tee /etc/apt/sources.list.d/pms.list |
Run the apt-get update commend again to refresh our repository list.
1 |
sudo apt-get update |
Finally, we can install the Plex Server. This will take a few minutes.
1 |
apt-get install plexmediaserver-installer |
Now, let’s set Plex to run under the Pi user.
1 |
sudo nano /etc/default/plexmediaserver.prev |
Your terminal window will fill with a big text document. Look for the line that says:
1 |
PLEX_MEDIA_SERVER_USER=plex |
Delete “plex” and type in your username (by default “pi”).
Now press CTRL+X then Y then ENTER.
Now restart the plex server:
1 |
sudo service plexmediaserver restart |
Now do a reboot:
1 |
sudo reboot |
3. Set a static IP address
We want our Raspberry Pi to have a static IP address so that every time we try access our Plex files, it knows where to look. Open up a new terminal and type the following command:
1 |
ifconfig |
You will get a screen similar to this:
Once your screen, note the IP address that follows “inet”. Jot this down or remember it.
Next, type the following command to get your router’s gateway address.
1 |
route -n |
Note the IP address under gateway. This is our routers address.
In the terminal, type:
1 |
sudo nano /etc/dhcpcd.conf |
Use your arrow keys to go navigate to the bottom of the file. Set your static IP address like this (change ip_address and routers values):
1 2 3 4 |
interface eth0 static ip_address=192.168.0.106 static routers=192.168.0.10 static domain_name_servers=8.8.8.8 |
After you are done, press CTRL+X then Y then ENTER to save the file. You may need to reboot your Raspberry Pi for these changes to take effect.
4. Map a Network Drive to your Raspberry Pi (optional)
If your files will be stored externally (not on the Pi or a storage device connected to it) you will need to make some additional changes. Whether you have a NAS or a router equipped with a USB port you will want to map your network drive.
Create a folder on your Raspberry Pi to mount the drive in.
I mounted mine at /home/pi/DRIVE/share
To do this, type these commands in your terminal (change ‘DRIVE’ and ‘share’ to whatever you want)
1 2 3 4 |
cd /home/pi sudo mkdir DRIVE cd DRIVE sudo mkdir share |
Now mount your drive to the directory you just created:
1 |
sudo mount -t cifs -o username=yourusername,password=yourpassword //NIGHTHAWK/S_Drive /DRIVE/share |
If you are using a external HDD connected to the USB port of your router, your username and password will be what you normally use to log in to your router settings. You can replace “NIGHTHAWK” with the gateway address of your router as well.
Otherwise, use the credentials you set up when you installed your NAS.
Now, navigate to your drive by browsing to its mount point
1 2 |
cd /home/pi/DRIVE/share ls |
If your see your files there, it worked.
To do this, we need to edit the /etc/fstab file, Run the following command to edit the /etc/fstab file:
1 |
sudo nano /etc/fstab |
User your arrow keys to navigate to the bottom of the file and add this (change as appropriate):
1 |
//DISK/share /home/pi/NIGHTHAWK/share cifs username=yourusername,password=yourpassword 0 0 |
Now press CTRL+X then Y then ENTER. All done! Your share will automount at boot.
5. Setting up your Plex Media Server
Now it’s time for the fun part — adding media to your media server!
On any computer connected to your network (including your Raspberry Pi itself), open a web browser and navigate to your Raspberry Pi’s static IP address like so (change ip address to yours):
1 |
http://192.168.0.106:32400/web |
You will see something like this. Go ahead and click ‘Add Library’.
Select your library type, click next, and browse to your network share, USB drive, or folder. Don’t click on a specific movie/show, just the root directory where they are stored.
After you do this for the rest of your media types, your library will begin to populate. You can see Plex is automatically adds Cover Art and media descriptions, which is nice!
6. Access your media from anywhere
The last step is to enjoy and watch your media from anywhere! Go ahead and download the Plex app to whatever device you want to watch your media on.
You can also access your media outside of your home network. Go into settings and make sure this is not disabled.
Another setting you can turn on/off is DLNA. DLNA allows devices that support it to be able to see and access your media server without downloading the Plex client or anything at all. It will just show up (if you’re on your home network).
As always, let me know if you have any questions or comments!