Raspberry Pi as Plex Server
Category : Raspberry Pi
I’m a proud mother of a 18 months old boy named Dante. I wanted to save all his photos in a place different from my smartphone but to have access to them whenever I’m home. So I thought it would be a great opportunity to use my Raspberry 4 which is laying around with no use.
Here I’ll show you how to install Plex Media Server on your Pi and to install vsftpd to transfer files from your computer to your Pi via FTP. I’m currently using the Raspberry Pi 4 Model B with Debian GNU/Linux 11 (bullseye) OS. To transfer files to your Pi you also have to install FileZilla on your computer. I’m using Linux Debian-11 OS on my laptop as well.
If you are using an Debian distribution, just type the following command in the command line to confirm your current version.
First of all you have to install Plex Media Server in your Rasp. Plex is a digital media player and streaming service that allows you to access music, pictures and videos stored on a device with any other device. Access https://www.plex.tv/ to know more about it.
You can type the following commands to install Plex. The first and the second commands are necessary to make sure that our Pi is up to date. The third command enables apt package manger to retrieve packages over HTTPS protocol used by Plex repository.
The fourth command downloads and saves the key in our keyrings directory. This way we can ensure that the files we are about to download are from the Plex repository and signed by the key. The tee command creates a file named plex-archive-keyring.gpg, skipping the standard output in the terminal.
The 5th command adds the plex repository to the sources list by adding the file plexmediaserver.list to the folder /etc/apt/sources.list.d . This file contains the web repository address and the address of the plex gpg key saved in the previous step.
To finish up, before we finally install plexmediaserver (7th command), we have to refresh the package list with apt-get update command because we added a new repository to our sources.
sudo apt-get update sudo apt-get full-upgrade sudo apt-get install apt-transport-https curl https://downloads.plex.tv/plex-keys/PlexSign.key | gpg --dearmor | sudo tee /usr/share/keyrings/plex-archive-keyring.gpg >/dev/null echo deb [signed-by=/usr/share/keyrings/plex-archive-keyring.gpg] htps://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list sudo apt-get update sudo apt install plexmediaserver
You don’t have to connect a screen every time you want to use Plex on your Rasp. Just set Chromium to startup where you left (or to open a specific page) and than create a file called chromium.desktop with an specification to open up Chromium when you log in. It’s important to set on your Pi to “Auto login” (You can do that also with Raspberry Pi Configuration Preference, shown bellow).
Save the file chromium.desktop in ~/.config/autostart/chromium.desktop with the following content:
[Desktop Entry] Type=Application Exec=/usr/bin/chromium-browser
Now we have to be able to save files in our Rasp with practicality. We just have to set up FTP (File Transfer Protocol) on Raspberry Pi for easy transferring of files over a network. First of all we make sure that SSH is enabled by using Raspberry Pi Configuration as shown bellow.
Now we’re going to install a FTP server software called vsftpd on our Raspberry Pi. The first command just do that. The second command opens the vsftpd.conf configuration file to modify some settings.
sudo apt install vsftpd sudo nano /etc/vsftpd.conf
Add or enable those settings bellow. The first and the second settings allow a single user with a local shell account to connect with FTP. The third setting enables the user to to upload files. The fourth setting change the mask to 022. The 5th setting prevents the FTP-connected user from accessing any file outside the directory tree. The last settings insert the username in our local_root directory path so our configuration will work for this user and any additional future users.
anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 chroot_local_user=YES user_sub_token=$USER local_root=/home/$USER/FTP
To finish the installation we create the files directory at /home/<user>/FTP. In my case the user is “michelle”. By using the -p argument mkdir creates the entire path tree. The second command removes the write permission from FTP directory to ensure no one can add files in to the FTP directory. Again I used “michelle” as user. Finally we need to restart the vsftpd.
mkdir -p /home/<user>/FTP/files chmod a-w /home/<user>/FTP sudo service vsftpd restart
Now we have to install FileZilla on the computer with this command.
sudo apt install filezilla
To find out the current IP address of your Raspberry Pi just type the following command line at your Rasp.
Back to the computer I set my Raspberry Pi IP to 192.168.1.152. I just type that in “Host”, michelle as my “Username”, my password, 21 in “Port” and click on “Quickconnect”.
Now I can transfer photos of my baby boy from other devices to my Pi and than access it with my smartphone through Plex App whenever I want.
To have more memory space the next step would be to set up my Pi as a NAS so I could transfer files to an attached storage. But that’s a story for another day. I hope you learned something new! Thanks for reading 😉
How to Setup a Raspberry Pi Plex Server
How to Setup FTP on the Raspberry Pi