How to Install a Plex Media Server on Alibaba Cloud

By Arslan Ud Din Shafiq, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Plex is a free software that lets you to stream all of your stuff on any device anywhere in the world. It supports a wide range of file types and supports all the major platforms including Windows, Linux, and OS X.

In this tutorial, we will be installing and setting up a Plex media server on an Alibaba Cloud Elastic Compute Service (ECS) with Ubuntu 16.04 installed.

Prerequisites

  • You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get $300 — $1200 worth in Alibaba Cloud credits for your new account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 2GB RAM and 2 Core processor (2.4 GHz or higher).

Setting Up Your Server

Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges.

# sudo apt update && sudo apt upgrade

Install Plex

You must create an account on https://www.plex.tv/features/ to get downloading link for installation of Plex.

You will need to download Plex. Always remember to get the latest version of Plex, otherwise, after login, you will not be able to find your server and you will see errors. To download, follow the steps below.

Step 1:

To download Plex Media Server copy, execute the following command.

# wget https://downloads.plex.tv/plex-media-server/1.13.5.5332-21ab172de/plexmediaserver_1.13.5.5332-21ab172de_amd64.deb

The above link may be changed when you install Plex, so keep in mind to get the link for latest release of Plex from official website.

Step 2:

Now de-package the downloaded .deb file by executing the command below.

# sudo dpkg -i plexmediaserver_1.13.5.5332-21ab172de_amd64.deb

Step 3:

Now start and enable Plex Media Server so that on rebooting system, Plex Media Server can start automatically.

To enable execute the command below.

# sudo systemctl enable plexmediaserver.service

To start execute the command below.

# sudo systemctl start plexmediaserver.service

Set Up Plex

Now you will need to create SSH tunnel to your Alibaba Cloud ECS. To do so, open terminal from your Linux installed laptop and execute the following command to connect to your server.

# ssh your_username@alibaba_cloud_ecs_ip_address -L 8888:localhost:32400

Now you will be able to access Plex via browser installed in your laptop as shown below. Use URL http://localhost:8888/web

Now you will be asked to login using your Plex account credentials. After login, you will be redirected to the following screen.

Now click Got IT! to proceed.

Close this window if you do not require a Plex Pass. It is required only if you are interested in using premium services like TV, mobile sync, exclusive forum access, trailers and extras. After closing it, you will see the following screen.

Remember to tick allow me to access my media outside my home and hit Next button, you will be redirected to following screen.

Now click next and you will be redirected to the following screen.

Click Done to proceed further.

Set Up Firewalls and Ports

If you have activated firewalls, you will have to define a rule in Alibaba Cloud security group for your cloud server to add exception for port 80/tcp and 443/tcp. You can enable these ports while creating ECS instance, but in case if you have forgotten to unblock these ports, you can follow the procedure in this guide: https://www.alibabacloud.com/help/doc-detail/25471.htm

Install Nginx

To install Nginx server, execute the command below.

# sudo apt-get install -y nginx

Now start and enable nginx server so that on system reboot, it can start automatically. To do so, execute the commands below.

# sudo systemctl start nginx
# sudo systemctl enable nginx

On successful installation, you will see the following screen.

Install Node.js:

To install Node.js, execute the command below.

# sudo apt-get install nodejs

Set Up Reverse Proxy

In this step, you will setup reverse proxy to access Plex so that you can access it via domain name without using any port in the end of address. To do so, execute the following command to create an nginx configuration file using nano editor.

# sudo nano /etc/nginx/conf.d/Plex.conf

Now add the following text in the opened file and save it.

server {
listen 80;
listen [::]:80;
server_name softpedia.xyz; location / {
proxy_pass http://localhost:32400/;
}
}

Now restart nginx server using the command below.

# sudo systemctl restart nginx

Now you can access your Plex Media Server via your Alibaba Cloud ECS IP address or domain name pointed to IP address. After accessing, you will be redirected to dashboard where you can add media files to your server.

In the end, you will have to create directories for TV and movies within a parent directory to store media files.

Navigate to home.

# cd ~

Create directories:

# mkdir -p plex-media/movies && mkdir plex-media/television

Install software-properties-common

Software-properties-common package is required to get the supported files for installation of SSL. In order to install software-properties-common package, follow the steps below.

To install software-properties-common execute the command.

# sudo apt-get install software-properties-common -y

Install SSL Certificate

To install SSL certificate using Let’s Encrypt, you will use Certbot. To do so, execute the following steps.

Update the package.

# sudo apt-get update

To install software-properties-common, execute the command below.

# sudo apt-get install software-properties-common

Add the certbot repository.

# sudo add-apt-repository ppa:certbot/certbot

Update the package to load the added certbot repository.

# sudo apt-get update

Now install python-certbot-nginx using the command below.

# sudo apt-get install python-certbot-nginx

Now issue SSL certificate to your domain by executing the command below.

# sudo certbot --nginx -d softpedia.xyz

Now restart nginx server using the command below.

# sudo systemctl restart nginx

Now you can see, your Plex media server is working fine and SSL certificate has been installed successfully.

Reference:https://www.alibabacloud.com/blog/how-to-install-a-plex-media-server-on-alibaba-cloud_594744?spm=a2c41.12842862.0.0

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.