Plex Media Server

Configuring a Plex Media Server on Ubuntu

C05348A3-9AB8-42C9-A6E0-81DB3AC59FEB
           

Plex_logo_2022.svg

Plex is a streaming media server that allows you to store and access media content on your system from any device. Based on the client-server model, Plex turns an ordinary system into a full-fledged media server. All media files are stored in a single system with a Plex server installed. The server organizes the media from your collection and from online services. You can then access the media on the server from any smartphone, smart TV, or streaming box. All you need is to have a Plex client installed on these devices.

You can install the Plex media server on many different operating systems, including Windows, Mac, Linux, and NAS OS. This article will show you how to install the Plex media server on Linux OS.

It is recommended to use the static IP on the server machine so that it will not get changed when the client tries to access it. For installation, you will require sudo privileges.

Open the command-line Terminal application to install Plex.

Note: The commands in this article were executed on Ubuntu.

Step 1: Download Plex Media Merver

The first step will be to download the Plex media server for Linux from its official Downloads page. Copy the URL of the latest release and substitute that version when running the following commands on your server:

wget https://downloads.plex.tv/plex-media-server-new/1.26.2.5797-5bd057d2b/debian/plexmediaserver_1.26.2.5797-5bd057d2b_amd64.deb

Step 2: Install your Plex Media Server

The next step after downloading is to install the Plex media server. Use the cd command to do so. Navigate to the directory where the downloaded file has been placed. Then, using the following command, install the downloaded Plex media server package onto your system:

sudo apt install ./plexmediaserver_1.26.2.5797-5bd057d2b_amd64.deb
sudo systemctl start plexmediaserver.service
sudo systemctl enable plexmediaserver.service
sudo systemctl status plexmediaserver.service

Step 4: Access your Plex Media Server

The Plex media server can be accessed and configured through its web interface using Port 32400. You will first need to open the local firewall to allow incoming connections to that port using the commands listed below. If you are running on EC2 on AWS or on any other Cloud provider, also make sure to allow traffic using a security group or equivalent

sudo apt install iptables-persistent
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 32400 -j ACCEPT
sudo netfilter-persistent save

You will notice that if you just go to the server's IP address at http://<server_ip>32400 you will be asked to authenticate, but you will then receive the following error:

"You do not have permission to access this server"

2021-11-19_13-03-41
Plex "You do not have permission to access this server"
© Copyrigh Videre Research, LLC. All rights reserved.

After much research, the solution that worked for me was to run the following command on my local system (substituting the IP address and access key of your server as appropriate) to open an ssh tunnel from your local system to the server on port 32400:

ssh -i ~/.ssh/<your_key>.key ubuntu@<your_host_ip> -L 8888:localhost:32400

With this connection open, open a browser window and navigate to: http://localhost:8888/web

You should now be able to configure this server.

Once it has been configured, you won't need to use this trick anymore.

Step 5: Configure your Plex Media Server

The next step is to configure access to your media files.

By default on Ubuntu, Plex is installed in /var/lib/plexmediaserver/Library/ but I don't recommend placing your media files there.

Plex runs as user plex, so all you have to do is create a new directory and give that user access:

sudo mkdir /home/media
sudo chown -R plex.plex /home/media

If your server does’t have a lot of local storage, I recommend using S3FS, which works pretty well for a &quot;normal&quot; Plex server and offers unlimited storage via AWS S3 at a reasonable price. See Install S3fs on Linux.

In order to make the files readable by Plex by default, you can add the uid=plex,gid=plex parameters to your fstab file:

sudo nano /etc/fstab

...
s3fs#<bucket_name>:/<directory>/ /home/media fuse _netdev,allow_other,passwd_file=/home/ubuntu/.s3fs-creds,defaults,uid=plex,gid=plex 0 0


sudo umount /home/media
sudo mount /home/media
ls -al /home/media

All of the files should now be owned by the plex user. You can use the AWS S3 console or the AWS CLI to upload your media files.<

Step 6: Update your Plex Media Serve

If a new version of Plex is released, you can install it using the following commands:

sudo apt update
sudo apt-get --only-upgrade install plexmediaserver

Note that in some cases apt updates will not install the latest current version of your Plex media server, in which case you will need to download it from their website at https://www.plex.tv/media-server-downloads/

To install, run:

wget https://downloads.plex.tv/plex-media-server-new/1.30.0.6406-f3f2fcc0a/debian/plexmediaserver_1.30.0.6406-f3f2fcc0a_amd64.deb
sudo dpkg -i plexmediaserver_1.30.0.6406-f3f2fcc0a_amd64.deb
Posted Comments: 0