Plex Media Server Installation on Linux
Plex Media Server organizes your video, music, and photo libraries and streams them to any device with automatic transcoding, metadata scraping, and remote access through Plex's global CDN. Installing Plex on a Linux VPS or bare-metal server gives you a reliable always-on media hub that serves your household or remote users without keeping a desktop powered on.
Prerequisites
- Ubuntu 20.04+, Debian 11+, or CentOS/Rocky 8+
- Minimum 2 GB RAM (4+ GB recommended for transcoding)
- Sufficient disk space for media (separate from OS drive recommended)
- Root or sudo access
- A free Plex account at
plex.tv
Installing Plex Media Server
Ubuntu/Debian:
# Download the latest .deb package
PLEX_VERSION="1.40.4.8679-424562606"
curl -LO "https://downloads.plex.tv/plex-media-server-new/${PLEX_VERSION}/debian/plexmediaserver_${PLEX_VERSION}_amd64.deb"
# Install the package
sudo dpkg -i plexmediaserver_${PLEX_VERSION}_amd64.deb
# Enable and start the service
sudo systemctl enable --now plexmediaserver
# Check status
sudo systemctl status plexmediaserver
Via official repository (auto-updates):
# Add Plex repository
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 -y plexmediaserver
sudo systemctl enable --now plexmediaserver
CentOS/Rocky Linux:
# Download and install RPM
PLEX_VERSION="1.40.4.8679-424562606"
curl -LO "https://downloads.plex.tv/plex-media-server-new/${PLEX_VERSION}/redhat/plexmediaserver-${PLEX_VERSION}.x86_64.rpm"
sudo rpm -ivh plexmediaserver-${PLEX_VERSION}.x86_64.rpm
sudo systemctl enable --now plexmediaserver
Initial Setup and Library Organization
For headless server setup, use SSH tunneling to access the web interface:
# On your local machine, create an SSH tunnel
ssh -L 8888:localhost:32400 user@your-server-ip
# Then open in your browser
# http://localhost:8888/web
Organize your media structure before adding libraries:
# Create organized media directories
sudo mkdir -p /media/{movies,tvshows,music,photos,home-videos}
# Set correct ownership
sudo chown -R plex:plex /media/
# If your media is on a separate mount, add plex to the group
sudo usermod -aG your-media-group plex
Recommended file naming conventions:
/media/movies/The Dark Knight (2008)/The Dark Knight (2008).mkv
/media/tvshows/Breaking Bad/Season 01/Breaking Bad - S01E01 - Pilot.mkv
/media/music/Artist Name/Album Name/01 - Track Name.flac
Add libraries in the Plex web UI:
- Click the + next to Libraries in the sidebar
- Select the library type
- Add your media folder (e.g.,
/media/movies) - Click Add Library
Transcoding Settings
# Check available CPU threads for transcoding
nproc
# Plex stores its transcoding temp files — set a fast location
# Default: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache/Transcode/
# Override to RAM disk for better performance:
sudo mkdir -p /tmp/plex-transcode
sudo chown plex:plex /tmp/plex-transcode
Configure transcoding in Plex web UI:
- Go to Settings > Remote Access (or the wrench icon)
- Navigate to Settings > Transcoder
- Set Transcoder quality: Make my CPU hurt (for best quality)
- Set Transcoder temporary directory:
/tmp/plex-transcode - Configure Maximum simultaneous video transcode based on your hardware
Optimize for direct play (minimize transcoding):
- Store media in H.264 MP4 (most widely compatible)
- Keep audio as AAC or AC3
- Use subtitles in SRT/ASS format (avoid image-based PGS for streaming)
Remote Access Configuration
Plex handles remote access automatically through Plex's relay infrastructure:
- Sign into your Plex account in the server settings
- Go to Settings > Remote Access
- Enable Enable Remote Access
- Optionally set a Manually specify public port (e.g., 32400)
Port forwarding for direct connections (bypasses relay):
# Open port 32400 on the server firewall
sudo ufw allow 32400/tcp # Ubuntu/Debian
sudo firewall-cmd --add-port=32400/tcp --permanent && sudo firewall-cmd --reload # CentOS
Nginx reverse proxy with TLS:
server {
listen 443 ssl;
server_name plex.example.com;
ssl_certificate /etc/letsencrypt/live/plex.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/plex.example.com/privkey.pem;
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;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s;
send_timeout 100m;
}
}
Hardware Acceleration
Plex Pass subscribers can use hardware acceleration for transcoding:
Intel Quick Sync (VAAPI):
# Install drivers
sudo apt install -y intel-media-va-driver-non-free vainfo
# Verify
vainfo | grep -i encode
# Add plex user to video/render groups
sudo usermod -aG video,render plex
sudo systemctl restart plexmediaserver
NVIDIA NVENC:
# Install NVIDIA drivers
sudo apt install -y nvidia-driver-535
# Verify GPU
nvidia-smi
# Add plex to video group
sudo usermod -aG video plex
sudo systemctl restart plexmediaserver
Enable in Plex: Settings > Transcoder > Use hardware acceleration when available.
Backup Strategies
# Plex stores its database and metadata here
PLEX_DATA="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server"
# Back up the database and metadata (stop Plex first for consistency)
sudo systemctl stop plexmediaserver
sudo tar -czf /backup/plex-backup-$(date +%Y%m%d).tar.gz \
--exclude="Cache" \
--exclude="Codecs" \
--exclude="Crash Reports" \
"$PLEX_DATA"
sudo systemctl start plexmediaserver
# Automate with a cron job
sudo crontab -e
# Add: 0 3 * * 0 systemctl stop plexmediaserver && tar -czf /backup/plex-$(date +\%Y\%m\%d).tar.gz "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server" --exclude=Cache && systemctl start plexmediaserver
Troubleshooting
Plex cannot find server after install:
# Verify the service is running
sudo systemctl status plexmediaserver
# Check listening port
sudo ss -tlnp | grep 32400
# Use SSH tunnel for initial setup on headless server
ssh -L 8888:localhost:32400 user@server-ip
# Then visit http://localhost:8888/web
Transcoding failures:
# Check Plex logs
sudo tail -f "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log"
# Check disk space for transcode temp
df -h /tmp
# Verify FFmpeg is available
ls /usr/lib/plexmediaserver/Plex\ Transcoder
Library not scanning new files:
# Trigger a manual scan via API (get your token from Settings > General > Troubleshooting)
TOKEN="your-plex-token"
curl "http://localhost:32400/library/sections/all/refresh?X-Plex-Token=${TOKEN}"
Conclusion
Plex Media Server on Linux combines professional-grade media organization with broad device support and a polished user experience, making it one of the most complete self-hosted streaming solutions available. By configuring hardware transcoding, a proper reverse proxy, and automated backups, you create a robust media infrastructure that serves multiple simultaneous users reliably without requiring a dedicated media PC.


