I used to run Plex, Sick Beard and CouchPotato all on a Windows 8 VM. It always annoyed me though in that I had to leave a terminal services connection open at all times for Plex to keep running. Then I upgraded the machine to the Windows 10 tech preview, and it drove me nuts rebooting itself every few days (yeah yeah, I know, it’s a tech preview).
So I decided to have a little fun and built a CentOS 7 VM to host my media centre instead. I was also curious to see if it would have better performance, and so far it seems to have improved a little from the clients I used to connect to it.
I’ve done this on CentOS, as opposed to Debian variants, because any skills learned translate better to the work I do with RHEL-based customers.
Server Setup
I provisioned a Windows 8 Hyper-V VM with 30GB space and 2GB of static RAM. 2GB should be plenty, unless you’re doing some intense transcoding with plex.
I installed CentOS 7 with the minimal install option, to help keep things lightweight.
Starting with some initial configuration of the server:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## Elevate to root: sudo su
## Update the Server yum update -y
## Turn off SELinux, because I can't be bothered configuring it for just my home network sed -i 's/enforcing/disabled/g' /etc/selinux/config /etc/selinux/config
## Fix the Startup Script to point to the /opt/ directory sed -i 's\ExecStart=/var/lib/CouchPotatoServer/CouchPotato.py --daemon\ExecStart=/opt/couchpotato/CouchPotato.py --daemon\g' /etc/systemd/system/couchpotato.service
Installing Headphones
I only just discovered headphones. I included it here as it looks interesting, but I haven’t really done anything with it yet.
## Fix the Startup Script to point to the /opt/ directory sed -i 's\/home/sabnzbd/headphones/Headphones.py\/opt/headphones/Headphones.py\g' /etc/systemd/system/headphones.service sed -i 's\/etc/headphones/headphones.ini\/opt/headphones/headphones.ini\g' /etc/systemd/system/headphones.service sed -i 's\/home/sabnzbd/.headphones\/opt/headphones/.headphones\g' /etc/systemd/system/headphones.service sed -i 's\User=sabnzbd\User=headphones\g' /etc/systemd/system/headphones.service sed -i 's\Group=sabnzbd\Group=headphones\g' /etc/systemd/system/headphones.service
Installing Plex
Things are easy here, as Plex distribute rpm packages for installation:
Now all of the services should be up and running. I don’t run sabnzbd at all, as I don’t use CouchPotato or Sick Beard to actually download anything. They’re just there to keep my media clean and organised.
Additionally, as long as your Router allows inbound connections on 32400 (or you’ve set up a forwarded port) then you should be able to connect Plex to the plex.tv site for remote access.
Bonus: Adding Nagios Monitoring
I run a Nagios server at home, mostly to fire alerts at me if this website goes down or my SSL certificate expires. Here’s what I did to enable monitoring of my new server, telling me if any of the services fall over:
## Enable & Start the Service systemctl enable nrpe systemctl start nrpe
Plex spins up more than one service, so you may notice a different configuration for that service check. I also found the machine breaches the standard check_procs limit of 250, so I bumped the tolerance up a little.
Bonus: Mounting a Windows Network Share
This wasn’t as straightforward as I would’ve liked. I’ve never mounted an SMB share before, only local drives, so it took me a while to get a solution with the correct permissions working.
## Setup user and group for the share (this user has the same name as an AD account with privileges to access the share) useradd -u 5000 mediaserver group -g 6000 mediaservergroup
## Add the Users that need access to the share usermod -G mediaservergroup -a sickbeard usermod -G mediaservergroup -a couchpotato usermod -G mediaservergroup -a headphones usermod -G mediaservergroup -a plex
## Create the folder that the share will live in mkdir /mnt/media
## Create a credentials file, with root only access sudo su cd ~ touch smb-credentials echo"username=mediaserver" >> smb-credentials echo"password={password}" >> smb-credentials chmod 0600 smb-credentials
## Add the entry to fstab to mount on boot (this is all one line) echo'//SERVER/Share /mnt/media cifs uid=5000,gid=6000,rw,credentials=/root/smb-credentials,file_mode=0775,dir_mode=0775 0 0' >> /etc/fstab
## Finally, mount the drive mount -a
The share should mount now on boot. I found if I didn’t specify the file_mode and dir_mode, then the mounted share would only have 0755 permission everywhere, preventing any software from making changes to the file system.