Hi All,
Well I decided to try something new after running Plex Media Server on my Windows 7 Media Centre (WMC) PC for a couple of weeks. Plex runs very well with my W7MC but there are a few short comings for my setup that have prompted me to try a Linux build, particularly a minimal headless build.
While all information to build a minimal Linux server is available, I didn't find one location that had all of the information, so I thought I would share my current build steps on CentOS. In time I'm hoping to expand this to include the installation of PlexConnect as my main client is an Apple TV 3.
The target audience for this guide are those that are new to a minimal build, specifically a build that is performed on the command line interface. I have tested these steps on CentOS 6.5 and 6.6 minimal installation media. I have tested these instructions purely in a VMWare instance, there are a few things I'm trying to get working before I install I build on bare metal.
This guide assumes that you are installing on a x86 64 bit architecture, not a 32-bit architecture, but I imagine that the steps will be similar.
The scope will cover from downloading CentOS to basic application and server configuration to get Plex running. Please feel free to suggest better solutions or steps - I'm no expert.
Ok, enough talk, to the guide.
Obtain and Install Centos 6.x
First step is to download the Centos Minimal installation media. Go to https://www.centos.org/download/ and select the 'Older Versions' area, as CentOS 7 is the current version. The site will direct you to available mirrors. The ISO file you want to get is name something like "Cents-6.6-x86_64-minimal.iso". Remember to download the appropriate 32-bit or 64-bit iso, this guide assumes you are using the x86_64 architecture. Now burn a copy of the CD if you are installing via physical media if required.
Boot up the PC using the Minimal CD and perform the following steps: (this is verbose for completeness):
- (Optional) Test the media, yes it will take a couple of minutes, but it will save hours if the media is corrupt.
- Select the appropriate system language for the CentOS system
- Select the appropriate keyboard layout, important for those that use a Dvorak Keyboard :P
- Select 'Basic Storage Devices' (unless you know what you are doing)
- Select 'Erase Whole Disk' - as the name implies it will wipe you entire drive (I will not be responsible for unintended data loss - if you are not sure STOP now! - this guide assumes you are installing to a fresh / formatted HDD)
- Name the Host - it is up to you, I use 'pms.localdomain' for Plex Media Server (not for the other common meanings), as long as the name is unique on your network.
- Important: select the 'Configure Network' option, this will open a Network Manager applet.
- Important: ensure the 'Connect Automatically' flag is set so after every reboot it will bring up the network.
- (Optional) Setup a static IP if you have planned out your network, this is recommended, but remember to set the correct IP, Gateway and DNS values - it is not the end of the world to use DHCP, but just more googling
![:) :)]()
- Set the server's correct Location and Time.
- Uncheck 'System Clock uses UTC' if your hardware has the correct time and date or leave it checked. If you don't know then uncheck it.
- Set the root user password. Don't set this to something easily guessed.
- Select 'Use All Space' as the installation option. Again this will erase your entire drive - make sure you are OK with this.
- Select 'Write Changes to Disk’ to start the installation process and grab a coffee.
At the end of the installation, CentOS will restart.
Configure Centos 6.x
In this section we will update the system, create and configure the ‘plex’ user that will be used to install and setup Plex Media Server and slightly secure the system. This will be done all within the Command Prompt… but don’t be scared.
To start we need to log in with the ‘root’ user after the PC has restarted. Use the login of ‘root’ without inverted comma’s and the password you gave root during the installation.
pms login: rootpassword: <root’s password>
Firstly we are best to update the system to get the latest Centos packages using the following command:
> yum update
Yum will automatically download and update any package that is currently installed. Yum will prompt you with a few questions, just reply with ‘y’ or ‘yes’ for all questions and you should be OK.
After we have updated all packages next we need to create a ‘plex’ user. This is the user that will install and generally run activities for the Plex Media Server. This will be a general user, but will be setup to run commands as the ‘root’ user if required.
To create the ‘plex’ user we use the following command:
> adduser -c "Plex Media Server User" -d /home/plex -s /bin/bash plex
This command will create a user ‘plex’ that has a home directory of ‘/home/plex/‘ and will be setup with the ‘bash’ shell. Don’t worry if that means nothing to you.
Next we have to give a password to the ‘plex’ user to activate (?) the user. We use the following command to prompt to set a password:
> passwd plex
You will be prompted to set a password and then prompted to confirm the password. This command is also used to change the password of a Linux user. Congratulations, you have created a new user from the command prompt.
Next we need to configure the ‘plex’ user to be allowed to run commands as ‘root’ using ‘sudo’. To do this we need to add ‘plex’ to the list of users that can use the ‘sudo’ command. use the following command to open the configuration file to do this:
> visudo
This will open the /etc/sudoers file in vi, an standard editor in Linux. Vi is not friendly to new users of linux. If you stumble with vi, you can use ’nano’ which is a more friendly editor. To use nano you will need first install with ‘yum install nano’. After yum has installed nano you can open the sudoers file with ‘nano /etc/sudoers’ command without inverted commas.
To add plex to the users you need to find the two lines in the sudoer’s file:
“## Allow root to run any commands anywhere
root ALL=(ALL) ALL”
then you need to add the following line after the line that mentions 'root':
“plex ALL=(ALL) ALL” so the 3 lines look like:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
plex ALL=(ALL) ALL
Save the file. That is it, the ‘plex’ user will now be able to use the ‘sudo’ command and run commands as a superuser.
So lets confirm that the ‘plex’ user has been setup correctly. Logout using the following command:
> exit
This will return you to the login prompt, next enter ‘plex’ and the plex password to login in with the new user.
pms login: plexpassword: <plex’s password>
If all is fine you will have a command prompt. Next we need to check that the ‘plex’ user can run the ‘sudo’ command. Try the following:
> sudo pwd
You will be prompted for a password… you need to use the ‘plex’ user’s password. You should get a response of ‘/home/plex’, the home directory of the plex user that was setup with the 'adducer' command. If you got an error then repeat the steps to update the /etc/sudoers file.
At this time you can use a SSH client to access you Plex Media Server, something like the Mac OS X ‘Terminal’ application or Putty on windows is fine. I usually perform the rest of the setup via SSH but you can perform all the steps on the Plex Server locally.
While using SSH to remotely access the Plex Server is helpful it is also recommended to block the ‘root’ user to use SSH remotely. To do this use the following command to open the SSH config file:
> sudo vi /etc/ssh/sshd_config
Again you can use ‘sudo nano /etc/ssh/sshd_config’ if you don’t like vi.
Search for the ‘# PermitRootLogin yes’, delete the hash (‘#’) character and change ‘yes’ to ‘no’. The result should be:
PermitRootLogin no
Save the file. After the next restart root will not be able to remotely login over SSH, but will be able to log in locally.
That is the ‘plex’ user set up!
Downloading and Installing Plex Media Server
Because we are using just the command prompt and Plex Media Service isn’t out of the box linked to a Plex Repository we can’t use the ‘yum’ command. There are ways we can use this but from the forums it appears that the latest version of Plex Media Server is not always available via this route. So we are going to use commands to get the latest version.
Before we can get the Plex, we need to install some applications to allow Centos to download the Plex Media Server package. Run the following command to install the wget application. Note: going forward it is assumed that you are logged in under the ‘plex’ user and is why you will see 'sudo' infront of commands.
> sudo yum install wget
This will install the wget application that can download files using a URL. We also need to get the latest URL for the current version of Plex to download.
I got the download URL by using another PC, going to the Plex downloads section and copying the Link to the current version. Now that we have the URL for the latest version it is time to download. I recommending creating a download’s folder in the ‘plex’ users home directory, but this is optional. To do this use the following commands to create and then open the download directory:
> mkdir ~/Downloads> cd ~/Downloads
Next we want to download the Plex package using:
> wget <URL of the Plex Media Server RPM package>
i.e. (current as of 24th May): Important, please check the current URL, below is an example.
> wget https://downloads.plex.tv/plex-media-server/0.9.12.1.1079-b655370/plexmediaserver-0.9.12.1.1079-b655370.x86_64.rpm
This will download the Plex package.
After the download has completed it is time to install! As we have downloaded the package to our Plex Server we can use the ‘localinstall’ option in yum to install from the downloaded file.
To install plex from the download we use the following command:
> sudo yum localinstall <Plex Media Server RPM package>
Based on the filename from above this would be: (Again check the filename based on the current Plex package)
> sudo yum localinstall plexmediaserver-0.9.12.1.1079-b655370.x86_64.rpm
The installation will take a minute or two. That is it, Plex is installed…. but it is not running, and the Linux firewall will stop clients connecting - Doh! But first let’s check the install.
To start plex we need to start the service using the following command. We only have to do this once after we install, after we reboot the Plex Media Server should start automatically on your Plex Server.
> sudo service plexmediaserver start
That should be it… Plex is running. But what about the firewall? At this time the firewall will block Plex ports.
We will disable the firewall for a moment to check that things are OK. In the final section we will configure the firewall to allow Plex to work as desired.
To disable the firewall temporarily use the following command:
> sudo service iptables stop
Caution: this will disable the firewall, after we have confirmed things are OK we will bring it back up.
Next is to check that we can use a Web Browser on another PC (or tablet, etc) to access Plex. For the purpose of this guide lets assume that the Plex Media Server has an IP of 192.168.1.100. Please change 192.168.1.100 with the IP of your Plex Server
Open a supported Web Browser and enter the following address, for example of the Plex Server having an IP of 192.168.1.100.
http://192.168.1.100:32400/web/
If all is OK then Plex should start. WooHoo. If not, well check the steps above to make sure you haven't missed anything. I would double check that you have disabled the firewall.
Note: previously there has been an issue with Centos 6.x and Plex producing a 404 error. I have seen this before in a desktop Centos install, but not yet in a minimal install <touch wood>. I can’t help here if you see this (yet).
OK, lets reboot the server to ensure that Plex starts up automatically and that the firewall also turned back on. Use the following command to restart:
> sudo shutdown -r now
The command will immediately restart the server.
Once restarted, login with the ‘plex’ user. Now to configure the firewall.
Configuring the firewall to work with Plex
The last step is to configure the firewall so the Server doesn’t block Plex traffic. I found this to be tricky, but this was my first attempt too ![:) :)]()
NOTE: This is my first attempt with iptable (firewall) configuration, I’m assuming that people will have other recommendations and I will gladly update the following to ensure the best configuration.
Assuming that you are logged in with the ‘plex’ user, run the following commands (note that each command should be one line):
> sudo iptables -A INPUT -p tcp -m tcp --sport 513:65535 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
> sudo iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 32400 -j ACCEPT
> sudo iptables -A INPUT -p udp -m state --state NEW -m udp --dport 32400 -j ACCEPT
> sudo iptables -A INPUT -p udp -m state --state NEW -m udp --dport 32410 -j ACCEPT
> sudo iptables -A INPUT -p udp -m state --state NEW -m udp --dport 32412 -j ACCEPT
> sudo iptables -A INPUT -p udp -m state --state NEW -m udp --dport 32414 -j ACCEPT
> sudo iptables -A INPUT -p udp -m state --state NEW -m udp --dport 1900 -j ACCEPT
> sudo iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
> sudo iptables -A INPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT
> sudo iptables -A INPUT -i eth0 -p udp -m udp --sport 53 -j ACCEPT
> sudo iptables -A INPUT -i eth0 -p tcp -m tcp --dport 443 -j ACCEPT
> sudo iptables -A INPUT -i eth0 -p tcp -m tcp --dport 80 -j ACCEPT
> sudo iptables -A OUTPUT -p tcp -m tcp -m state --state ESTABLISHED -j ACCEPT
> sudo iptables -A OUTPUT -o lo -j ACCEPT
> sudo iptables -A OUTPUT -p tcp -m tcp --sport 22 --dport 513:65535 -m state --state NEW,ESTABLISHED -j ACCEPT
> sudo iptables -A OUTPUT -p icmp -m icmp --icmp-type 0 -j ACCEPT
> sudo iptables -A OUTPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
> sudo iptables -A OUTPUT -o eth0 -p udp -m udp --dport 53 -j ACCEPT
> sudo iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 443 -j ACCEPT
> sudo iptables -A OUTPUT -o eth0 -p tcp -m tcp --dport 80 -j ACCEPT
> sudo service iptables save
This configuration will allow the Plex ports 32400, 32410, 32412, 32414 open. By default port 22 should be open from the base Centos installation. I have also opened DNS (53), HTTP (80) and HTTPS (443) in preparation of PlexConnect.
Again open a supported Web Browser on another PC and check you are able to connect to http://<IP address of Plex Server>:32400/web/ . If so - awesome.
Add you media to your server
Finally time to add your media to your server, and something I will leave up to you. Just remember that the plex user needs to have the right permissions to access your media if you are installing it locally as per the Plex Linux Guide in the FAQs.
I will also leave information about connecting to a SMB share or adding a local/external hard disk to Plex for other guides and posts in the forum. Once I get my Plex Server setup to successfully connect to a SMB mount on my NAS I might update this to cover the steps to install smb and firewall configuration if people will find it helpful.
Conclusion
I hope this guide is helpful for some people, at the very least this post will backup my steps if I need to reinstall
. Please let me know if you have any other suggestions to improve this process too!
Cheers,
Isomorphic
22/2/15 - Updated RPM Link with current version
24/5/15 - Updated RPM Link with current version