Plex Media Server is software to store all your digital media content and access it via a client application such as your TV, NVIDIA Shield, Roku, Mobile App, and many more platforms. Plex Media Server organizes your files and content into categories. It’s extremely popular with people storing TV Shows and Movie Libraries, and if your connection is good enough, share it with your friends and family. Over time Plex Media Server has grown much and now supports many platforms.
In the following tutorial, you will learn how to install Plex Media Server on Arch Linux. The tutorial will use the command line terminal with yay AUR helper. Ideally, most users may be using some wrapper for Pacman; for new users, it is essential to install one to keep your packages up-to-date while you learn Arch Linux.
Update Arch Linux
First, before you begin, make sure you update your system to make sure all existing packages are up to date to avoid any conflicts during the installation.
sudo pacman -Syu
Install yay Helper
To begin the installation, you must have GIT installed to import the yay repository to install/build. From your command terminal, use the following code to begin the installation.
sudo pacman -S --needed --noconfirm base-devel git
Now clone the yay archive using the following terminal command.
git clone https://aur.archlinux.org/yay-git.git
Next, move the archive to the /OPT/ directory. This is a good location for any other archive installs, keep everything located, and traditionally the directory is a commonly used area for different applications.
sudo mv yay-git /opt/
Now navigate to the yay-git directory location.
cd /opt/yay-git
Build the package using the makepkg command.
makepkg -si
Install Plex Media Server
Now that you have installed the yay AUR helper, you can begin to install Plex Media Server with the following command.
yay -S plex-media-server --noconfirm
Remove –noconfirm, which says yes automatically to the default installation messages to custom install.
Alternatively, a second build exists named the Plex Pass build that is maintained by another AUR maintainer, and this is a beta version that should be one step ahead of the current stable build at all times. However, do not be fooled by the name; you only get the server beta, not the plex pass features, for free.
Run the following command to install the alternative beta version.
yay -S plex-media-server-plexpass --noconfirm
Remove –noconfirm, which says yes automatically to the default installation messages to custom install.
By default, the Plex Media service should be automatically started, so use the following command to start the service and enable it on system boot.
sudo systemctl enable plexmediaserver --now
Next, verify the service is operational with no errors using the following systemctl status command.
systemctl status plexmediaserver
If the service is not active, use the following command to start Plex Media Server:
sudo systemctl start plexmediaserver
Next, enable on system boot.
sudo systemctl enable plexmediaserver
In the future, to restart the service, use the following command.
sudo systemctl restart plexmediaserver
Optional – Configure UFW Firewall
Before proceeding further, you should configure your UFW firewall if it is installed.
First, enable the firewall using the following command.
sudo ufw enable
Add the Plex Media Server port, which is 32400, and you can further lock this down to your IP by learning more about UFW Firewall in my tutorial “How to Install & Configure UFW Firewall on Arch Linux.”
sudo ufw allow 32400
Configure Arch Linux Headless Server SSH
For users with Plex Media Server installed on a remote Arch Linux headless server, you will first need to set up an SSH tunnel on your local computer for initial setup to allow outside connections.
Replace {server-ip-address} with your own for example 192.168.50.1 etc.
ssh {server-ip-address} -L 8888:localhost:32400
For users new to SSH, you may need to install it using the following command.
sudo pacman -S openssh
Ideally, you should install UFW if not present if you are planning long-term on using SSH with Plex Media Server to secure it.
Next, start the service.
sudo systemctl enable sshd --now
Now you can access the Plex Media Server by accessing the localhost in your web browser.
http://localhost:8888/web
Or the alternative if the above address does not work.
localhost:32400/web/index.html#!/setup
THROUGH AN SSH TUNNEL, the HTTP request will be redirected to http://localhost:32400/web, the remote server.
Once the initial setup is done, you will access your Plex Media Server with your remote server IP address.
https://{server-ip-address}:32400
Configure Plex Media Server in WebUI
Now that Plex is installed on your system, you need to configure and finish the setup through the WebUI. To access this, open your preferred Internet Browser and navigate to http://127.0.0.1:32400/web or http://localhost:32400/web.
Now, you can log in using an existing social media account listed above or with your e-mail to register a new account if you are new to Plex. Once logged in, you will begin the initial configuration setup.
Step 1. How Plex Works
The first configuration page describes what Plex is and how it works in a concise example.
Navigate to GOT IT! and leave a click to proceed to the next page.
Note, depending on the Internet Browser you use, and Firefox users will notice a message prompting to enable DRM; this choice is needed; without it, Plex WebUI may not work correctly.
Step 2. Optional Plex Pass
Next, you will be prompted to upgrade to Plex Pass possibly. This is optional; however, Plex Pass benefits HDR options and access to Beta builds. If you want to skip-click the “X” on the top right-hand corner, you can always set this up later.
Step 3. Server Setup
Configure your server name, and you can name this anything you desire, along with having the option to disable “Allow me to access my media outside my home.” By default, allowing access to media outside is enabled; if you are not going to do this, untick the feature.
Once configured, click the NEXT button.
Step 4. Media Library
The Media Library page gives you the option to pre-add your media directories. If you have a media drive or folder ready, click the ADD LIBRARY button.
Now select the type of media you want your folders to be organized into tv shows, movies, music, etc. Click the NEXT button to proceed to add folders.
Click the BROWSE FOR MEDIA FOLDER button and select the media directory.
The last option is that the Advanced options will appear once the folder is added. Here, you can further customize Plex to your liking.
Once done, click ADD LIBRARY to continue back to the initial configuration setup installation.
Step 5. Finishing up
Next, hit the NEXT button to finish the initial setup with or without adding a Media Library.
The next screen informs you that you are all set. Click the DONE button to proceed to Plex Dashboard.
Now you will arrive at your Plex Dashboard.
Configure/Setup Media Files & Folders Permissions
During the initial setup, you may have noticed that your media did not appear or have problems adding content that won’t be picked up. Plex refused to find the content on your existing hard drive’s internal and external secondaries. This is partly due to Plex creating a dedicated user account named plexuser, which needs to read and execute permission on your media directories.
Arch Linux permissions can be set using chown or setfalc; both are good. Some examples of how to apply are below.
sudo setfacl -R -m u:plex:rx /media/yourfolder/
sudo setfacl -R -m u:plex:rx /media/yourfolder/tv
sudo setfacl -R -m u:plex:rx /media/yourfolder/movies
These commands require the ACL package to be installed; if this is missing, use the following command to install.
sudo pacman -S acl
chown way example:
sudo chown -R plex:plex /media/yourfolder/
Or individual files in the hard drive if other folders are present that you do not want Plex to touch/access.
sudo chown -R plex:plex /media/yourfolder/tv
sudo chown -R plex:plex /media/yourfolder/movies
Configure/Setup Nginx as a Reverse Proxy
You can set up a reverse proxy to access Plex Media Server from a remote computer or network. In this example, the tutorial will set up an Nginx proxy server.
First, install Nginx, or given you are using Arch Linux, I would recommend installing Nginx Mainline, which even Nginx recommends over the stable variant.
sudo pacman -S nginx-mainline
If you experience and types hash issue, you need to increase it as the default installation sets this low, and it is recommended to increase it regardless to be safe. Open your main nginx.conf configuration files for the web service and under the HTTP { section adds the following line.
types_hash_max_size 4096;
Nginx should be enabled by default if it is not activated using the following command.
sudo systemctl enable nginx --now
Now check to make sure Nginx is activated and has no errors:
systemctl status nginx
sudo nano /etc/nginx/conf.d/plex.conf
You will need an active domain name which can be purchased for as little as 1 to 2 dollars if you do not have one. NameCheap has the best cheap domains going around and if you prefer a .com, use Cloudflare.
After you have created your sub-domain, add the following to the server block file:
server {
listen 80;
server_name plex.example.com;
location / {
proxy_pass http://127.0.0.1:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#upgrade to WebSocket protocol when requested
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
Save the file (CTRL+O), then exit (CTRL+X).
Now do a dry run to make sure no errors in the Nginx configuration or your server block:
sudo nginx -t
If everything is working correctly, the example output should be:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Reload Nginx for the change to take effect:
sudo systemctl reload nginx
If you have set up your domain and DNS records to point to your server IP, you can now access your Plex Media Server at plex.example.com.
Secure Nginx with Let’s Encrypt SSL Free Certificate
Ideally, you would want to run your Nginx on HTTPS using an SSL certificate. The best way to do this is to use Let’s Encrypt, a free, automated, and open certificate authority run by the nonprofit Internet Security Research Group (ISRG).
First, install the certbot package as follows.
sudo pacman -S certbot-nginx
Certbot replaces settings automatically. Often the first time applying, you should take a backup of your nginx folder just in case you need to fall back to configuration files that were custom created and configured quickly.
sudo cp /etc/nginx/ /etc/nginx-backup/
Once installed, run the following command to start the creation of your certificate:
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d www.example.com
During the certificate installation, you will get a notice to receive emails from EFF(Electronic Frontier Foundation). Choose either Y or N then your TLS certificate will be automatically installed and configured for you.
This ideal setup includes force HTTPS 301 redirects, a Strict-Transport-Security header, and OCSP Stapling. Just make sure to adjust the e-mail and domain name to your requirements.
Now your URL will be HTTPS://www.example.com instead of HTTP://www.example.com.
If you use the old HTTP URL, it will automatically redirect to HTTPS.
Optionally, you can set a cron job to renew the certificates automatically. Certbot offers a script that does this automatically, and you can first test to make sure everything is working by performing a dry run.
sudo certbot renew --dry-run
A great idea will be to test using a free SSL test such as DigiCert or SSL Labs.
Create Automatic Renewal Let’s Encrypt Service
Often it is best to create a timer for renewing your SSL certificates. While most Plex Media Servers will not be public-facing, when forgotten, it can go down at the worst possible times if the certificate expires.
First, install or use a text editor.
sudo pacman -S nano
Next, create a “systemd service file“ with nano as follows.
sudo nano /etc/systemd/system/certbot.timer
Next, copy and paste the following, you can adjust timings, but the below is recommended.
[Unit]
Description=Twice daily renewal of Let's Encrypt's certificates
[Timer]
OnCalendar=0/12:00:00
RandomizedDelaySec=1h
Persistent=true
[Install]
WantedBy=timers.target
Next, enable and start the “certbot.timer“ service with the following command.
sudo systemctl enable certbot.timer --now
How to Update/Upgrade Plex Media Server
By default, the Plex Media Server should alert you in the web console if an update is available. Once you know, there is one, you can check if the AUR maintainer has updated the maintained version using the following command.
yay -Syu --devel --timeupdate
Plex is quite popular, so while updates will not appear as soon as Plex releases it, they are often uploaded relatively quickly.
How to Remove (Uninstall) Plex Media Server
If you no longer wish to use Plex and want to remove it from your system, execute the following command to remove it.
yay -Rns plex-media-server --noconfirm
Users that installed Plex Media Server Plex Pass (Beta) use the following command instead.
yay -Rns plex-media-server-plexpass --noconfirm
yay -S plex-media-server-plexpass –noconfirm
Comments and Conclusion
Plex is an excellent media server software with great features and a very active community. I have tried many others, such as Emby, and always found myself coming back to Plex. Another great benefit is that Plex has some awesome 3rd party developers doing some community projects that are open source that you don’t see in other communities of this nature.