This gist walks through how to configure Plex Media Server on an Ubuntu 16.04 Server headless install. Through the rest of this tutorial, the server will be referred to as SERVER.
- The SERVER is configured with SSH access, either via local credentials, ssh-keypair or some other federated identity
- The SERVER is connected to the same LAN as all required data sources (if your storage is not on the same box, e.g. NAS)
You don't want the IP address of this SERVER (or any server) to change. Since it will be accessed only via internal IP address you can set that here.
NOTE: If you change the CIDR block on your network you will need to update the static IP address of the SERVER here or switch the static
method to dhcp
and remove the address
line. If you forget to do this the SERVER may be inaccessible.
# /etc/network/interfaces
=========================
...
# The primary network interface
auto eno1
iface eno1 inet static
address $STATIC_IP_ADDRESS
netmask $NETMASK
gateway $GATEWAY
dns-nameservers $PRIMARY_DNS $SECONDARY_DNS
Your plex server will need to think that all of your media data is local.
sudo apt-get install cifs-utils
mkdir /mnt/media
sudo chown -R $USER:$USER /mnt/media
Append this to the end of the below file to configure the mount and set credentials
# /etc/fstab
============
...
//$REMOTE_SERVER_IP/PATH/TO/REMOTE/MEDIA/DIRECTORY /mnt/media cifs username=$USERNAME,password=$PASSWORD,iocharset=utf8,sec=ntlm,auto 0 0
And finally run this command to mount the drive(s)
sudo mount -a
sudo su
crontab -e
# Add this line
0 4 * * * sudo reboot now
When you save this file crontab will automatically update and apply the new scheduled task.
echo deb https://downloads.plex.tv/repo/deb ./public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
sudo apt update
sudo apt install plexmediaserver -y
Create the file below with all contents, replacing $USER
with the name of the user you want to run Plex as
# /etc/systemd/system/plexmediaserver.service
=============================================
[Unit]
Description=Plex Media Server for Linux
After=network.target
[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
Environment=PLEX_MEDIA_SERVER_TMPDIR=/tmp
Environment=LD_LIBRARY_PATH=/usr/lib/plexmediaserver
Environment=LC_ALL=en_US.UTF-8
Environment=LANG=en_US.UTF-8
ExecStartPre=/bin/sh -c '/usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"'
ExecStart=/bin/sh -c '/usr/lib/plexmediaserver/Plex\ Media\ Server'
Type=simple
User=$USER
Group=$USER
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
sudo chown -R $USER:$USER /var/lib/plexmediaserver
sudo systemctl --system daemon-reload
sudo service plexmediaserver start
# /lib/systemd/system/plexmediaserver.service
=============================================
...
User=$USER
Group=$USER
...
At this point you can navigate to the IP of the server on port 32400 and configure plex. For remote access, set manual remote access to agree with the port you opened in the router To update, run the following command from command line
Every now and then you will see a banner across the top of Plex mentioning that an update is available. Follow the commands below to apply these updates.
sudo apt-get update
sudo apt-get install --only-upgrade plexmediaserver
NOTE: IF YOU FORGET THE --only-upgrade
FLAG THE INSTALL COULD OVERRIDE YOUR CURRENT INSTALLATION AND ALL RELATED DATABSE RECORDS. DON'T FORGET THIS FLAG!
# Stops the service
sudo service plexmediaserver stop
# Starts the service
sudo service plexmediaserver start