Skip to content
Andrew Parker edited this page Nov 4, 2020 · 60 revisions

Ultimate Torrent Setup

Introduction

Assumptions

This guide will help you setup the ultimate automatic torrent downloading solution. You will setup and configure, on Ubuntu server 20.04, rTorrent+ruTorrent, Sonarr, Radarr, Lidarr and Caddy as a reverse proxy for all these. This guide assumes that you would like to be able to access all these interfaces from anywhere on the Internet (using a login form secured with an SSL certificate) and that you have a domain name you will use. If you don't have a domain name yet see the section called Domain Name and Dynamic DNS at the end of this guide. Your domain name should alredy be set up and pointing to your external ip address which in turn should be forwarding to your Ubuntu box. The following ports need to be open in your firewall and forwarded to your Ubuntu box: 80 and 443 for access to the web interfaces, and 22 if you want ssh access remotely. The port that rTorrent is configured to use needs to be open, in this guide its 49155 by default.

How it Works

We will configure Sonarr, Radarr and Lidarr to use the rTorrent xmlrpc interface so they can add torrents directly. When the downloads finish, they will create a hard link to a final TV directory, AND we can continue to seed with the original file in the download directory with no problems. Even when we delete the file in the download directory, it won't affect the other hard link in the place where Sonarr placed it.
We'll also create some Ratio Rules that will seed a torrent of a specific tracker to a specified ratio and then automatically delete the torrent. So you won't have to monitor your torrents and manually clean them up when they've seeded enough, they will automatically seed to the perfect amount and then delete themselves.
The end result will be: you add a show to Sonarr, Sonarr will automatically search for new episodes and add it to rTorrent. The torrent will be downloaded in rTorrent and as soon as the download is complete, Sonarr will create a hard link of the file, rename it and place it in a nice, organized TV Shows folder. Meanwhile rTorrent will still be seeding the original file until it reaches the defined ratio, and then will auto delete the torrent and the original file from the download dir. 100% automated TV downloading! Radarr does the same thing for movies. Lidarr does the same thing for music.
You will probably want to download other torrents outside of Sonarr, Radarr and Lidarr. We will use the ruTorrent plugins autotools, ratio & extratio to accomplish what we want. The way these plugins work is best described by an example:
Say you have a directory /torrent for your torrent downloads. What you would do is create three sub dirs in that directory called watch, download and complete. Inside these directories will contain a mirrored directory structure for the different categories of torrents you download. So your structure might look like this:

So if you drop a torrent into /torrent/watch/tv, the torrent download is started in /torrent/download/tv. Also a label is automatically applied to the torrent based on the directory: in this example our torrent would receive the label tv. Once the torrent is finished downloading, a hard link will be created in /torrent/complete/tv. A hard link means that a duplicate file is made, but it shares the same data as the original. This is better than copying because it is instant and you don't have to duplicate the data on your hard drive. You can use the watch folders for other torrents you might download manually.

Install rTorrent, ruTorrent, Sonarr, Radarr, Lidarr

Login as your user then execute these commands one line at a time.

Update Ubuntu

sudo apt update

sudo apt full-upgrade -y

Make media group

Create a group named media. All the apps will be part of this group.

sudo addgroup --system media

sudo adduser $USER media

rTorrent

Install Prereqs

sudo apt install -y git acl curl build-essential automake libtool libcppunit-dev libcurl4-openssl-dev libsigc++-2.0-dev libncurses5-dev zlib1g-dev libssl-dev libchromaprint-tools zip unzip rar unrar mediainfo ffmpeg php-fpm php-geoip php-curl php-mbstring python-is-python3 python3-setuptools golang-1.14

sudo ln -s /usr/lib/go-1.14/bin/go /usr/bin

Compile xmlrpc

cd /usr/local/src

sudo curl -LOJ https://sourceforge.net/projects/xmlrpc-c/files/latest/download

sudo tar --no-same-owner -xzvf xmlrpc-c-*.tgz

sudo find . -type d -exec chmod a+rx {} \;

cd xmlrpc-c-*/

sudo ./configure

sudo make

sudo make install

Compile libtorrent

cd /usr/local/src

sudo curl -LOJ https://github.com/rakshasa/rtorrent/releases/download/v0.9.8/libtorrent-0.13.8.tar.gz

sudo tar -xzvf libtorrent-*.tar.gz

cd libtorrent-*/

sudo ./autogen.sh

sudo ./configure

sudo make

sudo make install

Compile rTorrent

cd /usr/local/src

sudo curl -LOJ https://github.com/rakshasa/rtorrent/releases/download/v0.9.8/rtorrent-0.9.8.tar.gz

sudo tar -xzvf rtorrent-*.tar.gz

cd rtorrent-*/

sudo ./autogen.sh

sudo ./configure --with-xmlrpc-c

sudo make

sudo make install

sudo ln -s /usr/local/bin/rtorrent /usr/bin/

sudo ldconfig

Install Caddy

cd /usr/local/src

sudo curl -LOJ https://github.com/caddyserver/xcaddy/releases/download/v0.1.5/xcaddy_0.1.5_linux_amd64.tar.gz

sudo tar -xzvf xcaddy_*.tar.gz xcaddy

sudo chown root:root xcaddy

sudo mv xcaddy /usr/bin

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/update-caddy -o /usr/local/bin/update-caddy

sudo chmod +x /usr/local/bin/update-caddy

sudo adduser --system --home=/var/lib/caddy --group caddy

sudo adduser caddy media

Make Directories

Create the webserver root for Caddy

sudo mkdir -p /var/www/public

Create and change directory to where you are going to download all your torrents to. For an example, this guide will use /data.
On your server, you will probably have a large chunk of storage configured on a certain mount point. The mount point is where you will want to change directories to.
It's important to realize that /data is just an example path that this guide uses, therefore, whenever you see /data in this guide be sure to change it to what the path to your storage actually is.

sudo mkdir /data

cd /data

Then execute this command which will create the folder structure I illustrated earlier:

sudo mkdir -p torrent/{complete/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other},download/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other},watch/{movie/radarr,music/lidarr,tv/sonarr,game,book,software,other}} Media/{Movies,'TV Shows',Music}

Make your user the owner of these folders and set the default permissions by executing these commands:

sudo chown -R $USER:media /data/*

sudo chmod -R 775 /data/*

or whatever your path is.
Then run the following to set the group ID and the default group ACLs on the data folders:

sudo find /data/* -type d -exec chmod g+s {} +

sudo find /data/* -type d -exec setfacl -m default:group::rwX {} +

Configure PHP and Caddy

Edit php configs

Edit /etc/php/7.4/fpm/php.ini and search for the line that contains date.timezone =. Set the value for your timezone from PHP Timezones. Mine looks like:

date.timezone = America/Denver

Edit /etc/php/7.4/cli/php.ini and do the same thing as above.

Edit /etc/php/7.4/fpm/pool.d/www.conf and change group and listen.group to:

group = media
listen.group = media

Search for env[PATH] and uncomment the line by deleting the semicolon:

env[PATH] = /usr/local/bin:/usr/bin:/bin

Add www-data user to media group
sudo adduser www-data media

Create dirs and keys for authentication
sudo mkdir -p /etc/caddy/auth/local

cd /etc/caddy/auth/local

sudo openssl genrsa -out jwt_privatekey.pem 2048

sudo openssl rsa -in jwt_privatekey.pem -pubout -out jwt_publickey.pem

sudo chown -R caddy /etc/caddy/auth/local/

Get Caddy config and enable the service
sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/Caddyfile -o /etc/caddy/Caddyfile

Edit /etc/caddy/Caddyfile and change the 4 instances of this to your actual domain name.

yourdomain.com

And change this to your actual email address.

youremailaddress@gmail.com

And change the two instances of unix//var/run/php-fpm/php-fpm.sock to

unix//run/php/php7.4-fpm.sock

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/caddy.service -o /etc/systemd/system/caddy.service

sudo service php7.4-fpm restart

sudo update-caddy

sudo systemctl enable --now caddy.service

journalctl -xe

Look for the line that looks like this:

{"level":"info","ts":1604297921.2970347,"logger":"http.handlers.auth_portal","msg":"created default superadmin user for the database","user_name":"webadmin","user_secret":"08f70914-4e9b-42be-8eb2-3aaa7fb62caf"}

The "user_name" and "user_secret" are the credentials you will use to login initially.
Browse to https://yourdomain.com/auth/settings/password and login with those credentials. Type in the current default password and then set a new password for your user. (We'll change the username later.)

sudo systemctl stop caddy.service

Edit /etc/caddy/auth/local/users.json and change

"username" to the username you want to login with
"address" to you email address
"domain" to the domain of your email address.

sudo systemctl start caddy.service

From now on, you will login with the username you set in the users.json file and the password you set earlier.

Configure rTorrent

Create rtorrent user and directories

sudo adduser --system --home=/var/lib/rtorrent --group rtorrent

sudo adduser rtorrent media

sudo mkdir -p /var/lib/rtorrent/session

sudo mkdir -p /etc/rtorrent

Get rTorrent config file:

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/rtorrent.rc -o /etc/rtorrent/rtorrent.rc

Edit /etc/rtorrent/rtorrent.rc and look for where it says

/CHANGE/THIS/PATH

for the directory path and edit the path for your setup. In our example, the directory path is the download directory we created previously, /data/torrent/download. Look for

HTPASSWD_WEBAUTH_USER

at the bottom and change it to the username you configured earlier in the caddy users.json file. Change any other random options that you want.

sudo chown -R rtorrent:media /var/lib/rtorrent/*

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/rtorrent.service -o /etc/systemd/system/rtorrent.service

sudo systemctl enable --now rtorrent.service

ruTorrent

Install ruTorrent

The script update-rutorrent will install ruTorrent and plugins automatically. Then whenever you run it again it will update ruTorrent and plugins that have updates.

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/update-rutorrent -o /usr/local/bin/update-rutorrent

sudo chmod +x /usr/local/bin/update-rutorrent

sudo update-rutorrent

Edit ruTorrent configs

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/plugins.ini -o /var/www/rutorrent/conf/plugins.ini

Edit /var/www/rutorrent/conf/plugins.ini
Edit to disable the plugins you don't want to use. You can leave it as it is to use the plugins that I use. The ones you have to keep are autotools, ratio, extratio and throttle.

Edit /var/www/rutorrent/conf/config.php
Change:

$saveUploadedTorrents = false;

Change $topDirectory to the top directory where your torrents are downloaded. In our example:

$topDirectory = '/data/';

Comment out existing $scgi_port and $scgi_host. Uncomment the ones below and change:

$scgi_port = 0;
$scgi_host = "unix:///var/lib/rtorrent/rtorrent.sock";

Change:

$profileMask = 0775;

Edit /var/www/rutorrent/plugins/autotools/conf.php
The $autowatch_interval variable is how often in seconds it looks in the watch folders for new torrent files. I changed mine to:

$autowatch_interval = 60;

Edit /var/www/rutorrent/plugins/filemanager/conf.php
Set the mkdperm to:

$fm['mkdperm'] = 775;

sudo chmod +x /var/www/rutorrent/plugins/filemanager/scripts/*

Edit /var/www/rutorrent/plugins/fileshare/conf.php
Set the $downloadpath variable to match the domain you will use to access your site:

$downloadpath = 'https://yourdomain.com/public/share.php';

sudo ln -s /var/www/rutorrent/plugins/fileshare/share.php /var/www/public/

Edit /var/www/rutorrent/plugins/unpack/conf.php
Set the following variable values:

$deleteAutoArchives = true;
$unpackToTemp = true;

Set permissions on share directory

sudo chown -R www-data:media /var/www/rutorrent/share/*

sudo find /var/www/rutorrent/share/* -type d -exec chmod 775 {} \;

sudo find /var/www/rutorrent/share/* -type f -exec chmod 664 {} \;

sudo service rtorrent restart

Sonarr

Install Sonarr, Bootscripts and Configure

sudo adduser --system --home=/var/lib/sonarr --group sonarr

sudo adduser sonarr media

cd ~

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0xA236C58F409091A18ACA53CBEBFF6B99D9B78493

sudo echo "deb http://apt.sonarr.tv/ master main" | sudo tee /etc/apt/sources.list.d/sonarr.list

sudo apt update

sudo apt install -y nzbdrone

sudo chown -R sonarr:media /opt/NzbDrone

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/sonarr.service -o /etc/systemd/system/sonarr.service

sudo systemctl enable --now sonarr.service

sudo service sonarr stop

Edit /var/lib/sonarr/.config/NzbDrone/config.xml and change:

<UrlBase>/sonarr</UrlBase>

sudo service sonarr start

Radarr

Install Radarr, Bootscripts and Configure

sudo adduser --system --home=/var/lib/radarr --group radarr

sudo adduser radarr media

cd /opt

sudo curl -L -O $( curl -s https://api.github.com/repos/Radarr/Radarr/releases | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 )

sudo tar -xvzf Radarr.*.linux.tar.gz

sudo rm Radarr.*.linux.tar.gz

sudo chown -R radarr:media /opt/Radarr

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/radarr.service -o /etc/systemd/system/radarr.service

sudo systemctl enable --now radarr.service

sudo service radarr stop

Edit /var/lib/radarr/.config/Radarr/config.xml and change:

<UrlBase>/radarr</UrlBase>

sudo service radarr start

Lidarr

Install Lidarr, Bootscripts and Configure

sudo adduser --system --home=/var/lib/lidarr --group lidarr

sudo adduser lidarr media

cd /opt

sudo curl -L -O $( curl -s https://api.github.com/repos/lidarr/Lidarr/releases | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 )

sudo tar --no-same-permissions -xvzf Lidarr.*.linux.tar.gz

sudo rm Lidarr.*.linux.tar.gz

sudo chown -R lidarr:media /opt/Lidarr

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/lidarr.service -o /etc/systemd/system/lidarr.service

sudo systemctl enable --now lidarr.service

sudo service lidarr stop

Edit /var/lib/lidarr/.config/Lidarr/config.xml and change:

<UrlBase>/lidarr</UrlBase>

sudo service lidarr start

Configure the GUI Settings

ruTorrent

First browse to https://yourdomain.com/rutorrent
You will be presented with the login window:

Login with the username and password you created earlier.

Click on the gear cog to enter the settings.
In Autotools enable all the options and browse to your complete and watch directories. Also, be sure to select Hard Link for the operation type. Enter the following in the Automove filter box:

/^(?!tv\/sonarr$|movie\/radarr$|music\/lidarr$).*$/

In History I only check Deletion. This is nice because Sonarr could download a torrent, seed it to 2.0, and delete it all while you are sleeping. So the History plugin will let you see a record of when it was deleted and what your ratio was, just for your sanity:

In Unpack check enable autounpacking:

In Ratio Groups set up a default group and a Sonarr group:

Click ok. Then click on the wrench/screwdriver next to the gear cog and click on Ratio Rules. Set up a rule for Sonarr:

You can setup another Ratio Rule for Radarr downloads too, if you want. Alternatively, you could set up ratio rules for each individual tracker by selecting "One of torrent's tracker URLs contain" from the drop down list.

Now when you add a torrent you just click on the directory button and choose which category it is. Then it will automatically receive that label and it will download to the proper directory.

Sonarr

Now browse to https://yourdomain.com/sonarr
Click on Settings and you'll see the Media Managment tab.

Move the switch to Shown next to Advanced Settings. Switch Rename Episodes to Yes. Set the renaming formats to the way you want. Mine are set to conform to Plex naming standards.

Enable Delete empty folders and Ignore Deleted Episodes.

Change the File chmod mask to 0664 and the Folder chmod mask t0 0775 and the chown Group to media.
Click the Save button.

Click on the Indexers tab.

Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.

Click on the Download Client tab.

Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/tv/sonarr.

Click on the General tab.

Turn Open browser on start to No. Change Log Level to Debug.

Click on Series -> Add Series -> Import Existing Series On Disk
Browse to your TV Shows folder. In our example it would be /data/Media/TV Shows/

Click the close button.

Radarr

Now browse to https://yourdomain.com/radarr
Click on Settings and you'll see the Media Managment tab.

Move the switch to Shown next to Advanced Settings. Switch Rename Movies to Yes. Set the renaming formats to the way you want. Mine are set to conform to Plex naming standards.

Enable Ignore Deleted Movies. Set File chmod mask to 0664 and Folder chmod mask to 0775 and chown Group to media.
Click the Save button.

Click on the Indexers tab.

Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. (Required Flags is optional. My setting makes it so it will only download approved torrents from PTP.) If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.

Click on the Download Client tab.

Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/movie/radarr.

(Optional) Click on the Custom Formats tab.
Custom formats are a very powerful advanced feature. You can use them to fine tune how you search for releases. This example is for PTP.

Click the plus button and click Custom. These settings match any release that is not labeled Scene by PTP.

Add another Custom format. These settings match Golden Popcorn releases from PTP.

(Optional cont.) Click on the Profiles tab.
Click on the Profile you plan to use.


Set a Custom Format Cutoff and set the order of the Custom Formats (higher in the list is more preferred). This example creates a profile that will download a scene release if it's the only release available, will upgrade to a non-scene release if/when it becomes available, and will upgrade to the Golden Popcorn release if/when it becomes available.

Click on the General tab.

Turn Open browser on start to No. Change Log Level to Debug.

Click on Add Movies -> Bulk Import Movies
Browse to your Movies folder. In our example it would be /data/Media/Movies/

Click Ok then click the green check mark.

Lidarr

Now browse to https://yourdomain.com/lidarr
Click on Settings and click the Media Managment tab.

Check Rename Tracks. Set the renaming formats to the way you want.

Check Delete empty folders.

Check Ignore Deleted Tracks. Set File chmod mask to 0664 and Folder chmod mask to 0775 and chown Group to media.
Click the Save Changes button.

Click on the Indexers tab.

Click the plus button to add your desired providers. Configure the provider with the info it asks for, which you will usually find in your respective rss feed url for the tracker. If your tracker does not support search, I would suggest checking out Jackett. It is a separate webapp that adds search capabilities to many trackers. I haven't used it personally, but I've heard it works well.

Click on the Download Clients tab.

Click the plus sign and click rTorrent. Use these settings. In our example the Directory value would be /data/torrent/download/music/lidarr.

Click on the General tab.

Uncheck Open browser on start. Change Log Level to Debug.

Click on Artist -> Import Existing Artist(s) and click Start Import
Browse to your Music folder. In our example it would be /data/Media/Music/

Click Ok.

Conclusion

Now that everything is configured you can add TV shows to Sonarr and movies to Radarr and watch the magic. You can update rTorrent, Sonarr, Radarr and Caddy using yay. You can keep ruTorrent up to date by running the update-rutorrent script again.

Enjoy 100% automated TV and movie downloading!

Optional Extras

These are some additional things you can do that make this setup even better.

Notifications

Sonarr, Radarr and Lidarr have the ability to notify you when they start a download and finish a download. My favorite provider, and the one I use, is Pushover. Pushover supports both iOS and Android and is simply a one time purchase rather than a monthly subscription.

Sonarr & Radarr & Lidarr

Click Settings -> Connect. Check Pushover (or your provider of choice) and configure the settings.

Now you will receive a notification when ever a show or movie starts and finishes downloading.

Mobile Access

Now that everything is setup, you'll probably find yourself wanting to access these interfaces from your mobile device. I have an iPhone, so all the screenshots will be from that, but since these are all webapps, this should work from any device.

ruTorrent

A mobile plugin was created by zebraxxl, but it appears he has abandoned it. I have created a fork of rutorrentMobile and made a number of enhancements. The update-rutorrent script is set to automatically install this plugin so it should already be installed. Now from your mobile browser, browse to https://yourdomain.com/rutorrent and you should see the mobile interface for rutorrent. Add to your mobile home screen to create a web app.

Sonarr & Radarr & Lidarr

Sonarr, Radarr and Lidarr have a responsive design that is very functional on a mobile device. From your mobile browser, browse to https://yourdomain.com/sonarr and you should see the interface for Sonarr. Add to your mobile home screen to create a web app. Do the same for Radarr and Lidarr.

Resilio Sync watch folders

Resilio Sync is like Dropbox, but instead of syncing to the cloud first, the folders sync from Peer to Peer. We can set up Resilio Sync on our watch directory so that we are able to drop .torrent files into those directories from any device. On iOS for instance, you can download a .torrent file in Safari and then use the Open with... option to place the file in one of the watch folders, depending on the category. Then Resilio Sync will sync that file to all the Peers connected to it, includng our Ubuntu server, which means the .torrent file will be downloaded to the correct watch folder and picked up by ruTorrent immediately!

cd ~

wget -qO - https://linux-packages.getsync.com/resilio-sync/key.asc | sudo apt-key add -

sudo echo "deb http://linux-packages.getsync.com/resilio-sync/deb resilio-sync non-free" | sudo tee /etc/apt/sources.list.d/resilio-sync.list

sudo apt update

sudo apt install -y resilio-sync

sudo adduser rslsync media

sudo mkdir /etc/systemd/system/resilio-sync.service.d

sudo echo -e "[Service]\nGroup=media" | sudo tee /etc/systemd/system/resilio-sync.service.d/override.conf

sudo systemctl enable resilio-sync.service

sudo service resilio-sync restart

Now browse to https://yourdomain.com/sync
Fill in a username only and click Continue.

Fill in a name, agree to the terms and click the Get started button.

Click the + button and Standard Folder button:

Browse to your watch directory. In our example it is /data/torrent/watch/. Then click the Open button.

Now click the 3 dots menu next to the folder and click Preferences:

Configure it how you want. This is how I have mine configured.

Now you can click the Share button and use the Key to add your Desktop client or the QR code to add the mobile client.
When you download a torrent click the Open in > Copy to Sync option and then the Sync app will launch.

Just browse to the correct watch folder, based on the category of torrent, and then it will sync back to your Ubuntu server and be picked up and started immediately by ruTorrent and receive the correct label based on the folder you placed it in.

Plex Media Server

In order to view all your media you will want to use a media server. My media server of choice is Plex and we can run Plex Media Server right on our Ubuntu box that contains all our media. There is a script by mrworf that will download and install the latest version of Plex. We will set up that script and use it to install Plex Media Server.

cd /opt/

sudo git clone https://github.com/mrworf/plexupdate.git

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/update-plexmediaserver -o /usr/local/bin/update-plexmediaserver

sudo chmod +x /usr/local/bin/update-plexmediaserver

sudo mkdir /etc/systemd/system/plexmediaserver.service.d

sudo echo -e "[Service]\nGroup=media\nUMask=0002" | sudo tee /etc/systemd/system/plexmediaserver.service.d/override.conf

If you don't have a Plex Pass, then edit /usr/local/bin/update-plexmediaserver and add a -p argument to the command so that it will download the public version. I would suggest purchasing a Plex Pass.

Now you can run the following to install Plex Media Server. Run it again in the future to update to the latest version.

sudo update-plexmediaserver

sudo adduser plex media

sudo service plexmediaserver restart

From a computer on the same network as your Ubuntu server, browse to http://ubnutu.server.local.ip:32400/web and login with your Plex credentials.
If your Ubuntu server is on a different network (in the cloud for example), you'll first need to set up an SSH tunnel so that you can access things as if they were local. This is only necessary for the initial setup.
Follow the instructions here at the bottom of the page where it says "On a Different Network" to set up the ssh tunnel.

Name the server and click Next.

Click Add Library.

Click Moves and click Next.

Browse to your Movies folder. In our example it was /data/Media/Movies

Click Add Library again and select TV Shows.

Browse to your TV Shows folder. In our example it was /data/Media/TV Shows

Click Next and then click Done.

Click the settings button in the top right and click the Server section. Click on the Library tab and click the Show Advanced button. Enable Update my library automatically. Enable thumbnail generation when media is added.

Click on Scheduled Tasks and enable all the tasks.

Edit any other settings you might want then restart Plex Media Server.

sudo service plexmediaserver restart

Now that Plex Media Server is running you can access your media using one of the Plex clients and stream your media where ever you want! Plex will attempt to use UPnP to automatically configure your firewall to allow access remotly. If your router/firewall does not support that, you will need to manually open port 32400. Then in the Server settings enable Manually specify public port in the Remote Access settings.

Tautulli

Tautulli is a 3rd party application that you can run alongside your Plex Media Server to monitor activity and track various statistics. Most importantly, these statistics include what has been watched, who watched it, when and where they watched it, and how it was watched. You can also use it for notifications for recently added items to Plex libraries and start of playback, etc.

sudo adduser --system --home=/var/lib/tautulli --group tautulli

cd /opt/

sudo git clone https://github.com/Tautulli/Tautulli.git

sudo chown tautulli:tautulli -R /opt/Tautulli

sudo curl https://raw.githubusercontent.com/xombiemp/ultimate-torrent-setup/master/tautulli.service -o /etc/systemd/system/tautulli.service

sudo systemctl enable --now tautulli.service

sudo service tautulli stop

Edit /var/lib/tautulli/config.ini and change:

http_root = /tautulli

sudo service tautulli start

Now browse to https://yourdomain.com/tuatulli
Click Next to start the wizard.
Login to your Plex account and click Next.


Select your Plex instance on it's local IP Address and Click Verify. Then click Next.


Click Next through the other prompts and finally click Finish.

Click on the gear cogs in the top right to enter settings. Click the Show Advanced button and then click on the Web Interface menu.

Uncheck Launch Browser on Startup and check Enable HTTP Proxy. Click the Save button. (don't restart if it ask you to)

Click on the Plex Media Server Menu.

In the Logs Folder box paste in /var/lib/plex/Plex Media Server/Logs/. Check Monitor Plex Updates and choose your Update Channel and choose Linux - Fedora 64-bit for the Release. Check Monitor Plex Remote Access.

Click on the Notifications & Newsletter menu.

Check Group Notifications by Season or Album and Group Notifications by TV Show or Artist.

Click the Notification Agents menu and click Add new notification agent.

Configure your Pushover (or other provider) settings. Then click the Triggers tab.

Check the boxes for the events you want notifications for. I check Playback Start, Buffer Warning, User Concurrent Streams, Recently Added, Plex Update Available, Tautulli Update Available.
Click the Test Notifications tab.

Click the Test button and confirm that you receive the test notification and then click Save.

Domain Name and Dynamic DNS

To be able to access your resources remotely and secured with an SSL certificate, you will need to set up a domain name. You'll need to purchase a domain name from a registrar and then configure the DNS records to point to your IP address. Most often, with residential ISP accounts, you will have a dynamic IP address that changes often. In order to configure a domain name to point to your IP address you will need to use a dynamic dns service that will update your DNS records whenever your IP address changes. The registrar I chose, Namecheap, is inexpensive and also includes a free dynamic dns service. In this section I'll show you how to purchase your domain name and configure the dynamic dns client to run on the Ubuntu machine.
Browse to https://www.namecheap.com and search for a domain name you want in the search box. Once you find a domain you want that is available, continue on to purchase the domain name.
Once you have your domain name purchased, follow the instructions here to enable Dynamic DNS on your account and get your Dynamic DNS Password. Then follow the instructions here to create the host record that will be updated dynamically.
Now we'll install the dynamic DNS client on the Ubuntu machine. Just accept all the defaults for the ddclient installation.

sudo apt install -y ddclient

sudo curl https://raw.github.com/xombiemp/ultimate-torrent-setup/master/ddclient.conf -o /etc/ddclient.conf

Edit /etc/ddclient.conf
Change the login and password fields to be your domain name and your Dynamic DNS Password that we got earlier. For more information on this config file, check out this Knowlagebase Article.

sudo service ddclient restart

The dynamic dns client should be working now and will automatically update your DNS records whenever your IP address changes. Check your DNS records in Namecheap to make sure that it has automatically added a DNS record.