14 C
Texas

How To Install Plex Media Server on Ubuntu 18.04

Today we are going to learn that how to install Plex Media Server on Ubuntu 18.04. Before going to installation process let’s have a short introduction about Plex Media Server.

Plex is an Open Source software by which you can easily manage your Videos, TV shows, Music lists, Images and much more with the elegant interface. It also stream these media files on your Computer, Smartphones, TV and other such devices using the Network.

So, just follow the below steps to easily install the Plex Media Server on your Ubuntu system.

Step 1: Update Your System

As usaul we do, update your system by typing

- Advertisement -
sudo apt update 

Step 2: Download Plex Media Server

Visit the Plex Server official release page to download the latest version of the Plex. You can also get it using the wget command as given below

wget https://downloads.plex.tv/plex-media-server-new/1.18.8.2527-740d4c206/debian/plexmediaserver_1.18.8.2527-740d4c206_amd64.deb
How To Install Plex Media Server on Ubuntu 18.04

Now, switch to the directory where package is downloaded.

cd ~/Downloads

And then run the following command to install deb package.

sudo dpkg -i plexmediaserver_1.18.8.2527-740d4c206_amd64.deb
How To Install Plex Media Server on Ubuntu 18.04

As the Plex Media Server is installed, verify the stauts of it by typing

sudo systemctl status plexmediaserver

Output:

You’ll see the similar output

How To Install Plex Media Server on Ubuntu 18.04

In case it is not started run the given command to start its services

sudo systemctl start plexmediaserver

Step 3: Enabling Plex Repository

After enabling the Plex repository on Ubuntu system, you can easily update the latest version of it. As the plex media server deb package contains a source list file. Type the command to see a list of files that are being installed from a package.

dpkg -L plexmediaserver

Now, open the file by running

sudo nano /etc/apt/sources.list.d/plexmediaserver.list
Then uncomment the last line of the file as seen below
How To Install Plex Media Server on Ubuntu 18.04

After it save and exit the file.

Now, import the Plex Media Server public key to the apt package manager.

wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add -
How To Install Plex Media Server on Ubuntu 18.04

And update your system

sudo apt update

Step 4: Initializing Plex Media Server

Run the below command to check the address on which Plex Media Server is listening on.

sudo netstat -lnpt | grep Plex
How To Install Plex Media Server on Ubuntu 18.04

Here you can see that Plex is listening to 0.0.0.0:32400 & 127.0.0.1:32401

So, type 127.0.0.1:32400 in your browser and hit enter. You’ll be directed to the Welcome page of Plex as an initial setup.

Provide Plex TV Account

Here you’ve to provide your Plex TV account to sign in.

For security reason, if the Plex is already installed on the remote system, set up SSH by executing the below command

ssh 10.20.39.45 -L 8888:localhost:32400

After it run the below command to access the Plex Web Interface

http://localhost:8888/web

It will redirect to the http://localhost:32400/web on the remote system by using SSH tunnel. It will only require for first time setup. After it you can access the web interface by IP:32400.

Note: Substitue your IP address.

Configure Plex Wizard

After doing these changes, you will be directed to do the initial setup.

You can also type the below address if the above can not redirect you.

localhost:32400/web/index.html#!/setup

Now, provide the name for your Plex and check the Allow me to access box.

Then click on the Next button.

On, the next screen you can add library by clicking on Add Library button.

Choose your library type, and navigate to media folder to add media directories.

Make sure you’ve the read & execute permissions otherwise it will not work. Run the command to give permissions to the Plex.

sudo setfacl -m u:plex:rx /media/linuxbabe/

For single directory permission, run the command like this

sudo setfacl -m u:plex:rx /media/linuxbabe/directory-name

As it is tempting to add the recursive flag (-R) that will provide read & execute permissions on each file & directories and their sub-directories.

sudo setfacl -R -m u:plex:rx /media/linuxbabe/

Do this only if you’ve the media on your hard-drive I don’t recommend if you’ve some sensitive data.

After adding the media directories click on the Next button.

Now, click on Done to finish up.

If you got any error, don’t worry just delete the following file & try to do the setup again carefully in order to prevent any error.

sudo rm /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml
sudo systemctl restart plexmediaserver

And then go to localhost:32400/web and claim the unclaimed server.

If you’ve your own domain name you can also use that one for this purposes.

Step 5: Creating Nginx Reverse Proxy

As said earlier if you are going to use your domain name, you’ll have to create the reverse proxy. To do this install nginx if you don’t have already installed.

sudo apt install nginx

After it make a server block config file.

sudo nano /etc/nginx/conf.d/plex.conf

Then paste the following date into the file.

server {
listen 80;
server_name plex.example.com;

location / {
proxy_pass http://127.0.0.1:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#upgrade to WebSocket protocol when requested
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}

Then save and exit the file.

Note: Replace the plex.example.com with your domain name. And don’t forget to add the DNS records for sub-domain in DNS manager.

Verify that the nginx is working fine by testing the syntax

sudo nginx -t

And restart the nginx services.

sudo systemctl reload nginx

Step 6: Encrypting with HTTPS

For security reasons, enable the HTTPS in order to stay secure. You can use certbot for this purpose.

So, install certbot & nginx plugin for certbot.

sudo apt install certbot
sudo apt install python3-certbot-nginx

Now, get the TLS certificate by running

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d plex.example.com

The certificates will be installed easily & automatically then you can access the Plex with https function.

Step 7: Upgrade Plex on Ubuntu

As we’ve added the repository earlier, so you can update & upgrade the Plex by running

sudo apt update
sudo apt upgrade
sudo systemctl restart plexmediaserver

So, this is how you can install Plex Media Server on Ubuntu 18.04.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article