Technology Encyclopedia Home >How to Install Plex Media Server on a VPS — Stream Your Library Anywhere

How to Install Plex Media Server on a VPS — Stream Your Library Anywhere

I have movies and TV shows that I own on physical media and have ripped over the years. I want to watch them from any device without carrying hard drives around. Plex is what I use to make that work.

The polished client apps are the main reason Plex has such a large user base — smart TVs, phones, browsers, game consoles all have proper clients. Setup involves one initial step that's easy to miss: Plex needs to be accessed from a local network browser for the initial setup, which requires an SSH tunnel if your server doesn't have a local browser. I'll make that clear.

I run Plex on Tencent Cloud Lighthouse. For direct play (no transcoding), almost any plan handles it well — Plex's streaming overhead is mostly bandwidth, not CPU. For transcoding, a 2–4 vCPU plan provides adequate throughput. Lighthouse's CBS cloud disk expansion handles media library growth cleanly: attach additional storage volumes as your collection grows without disrupting Plex's library configuration. The OrcaTerm browser terminal is also useful for the initial Plex setup, where you need to access the server from a local network browser — I'll show you how to handle that.

I run Plex on Tencent Cloud Lighthouse. The key consideration for Plex is bandwidth — your server needs enough outbound bandwidth to stream to your clients, especially if multiple people are watching simultaneously.


Table of Contents

  1. Plex Architecture and What You Need
  2. Prerequisites
  3. Part 1 — Install Plex Media Server
  4. Part 2 — Initial Setup via SSH Tunnel
  5. Part 3 — Configure Nginx Reverse Proxy
  6. Part 4 — Enable HTTPS
  7. Part 5 — Add Media Libraries
  8. Part 6 — Upload Media
  9. Part 7 — Plex Pass Features
  10. Part 8 — Backups
  11. The Gotcha: Initial Setup Requires Local Network Access
  12. Maintenance Commands

  • Key Takeaways
  • Use the appropriate Lighthouse application image to skip manual installation steps where available
  • Lighthouse snapshots provide one-click full-server backup before major changes
  • OrcaTerm browser terminal lets you manage the server from any device
  • CBS cloud disk expansion handles growing storage needs without server migration
  • Console-level firewall + UFW = two independent protection layers

Plex Architecture and What You Need {#architecture}

Your Cloud Server (Plex Media Server)
         ↕ streams via HTTPS
Your Devices (Plex App on phone, TV, browser)

Plex transcodes media if the client can't play the original format. On a VPS without GPU, this is CPU-intensive. For best results:

  • Store media in h.264 MP4 format (most clients direct-play this)
  • Or subscribe to Plex Pass for hardware transcoding support

Prerequisites {#prerequisites}

Requirement Notes
Cloud server Tencent Cloud Lighthouse Ubuntu 22.04
2 GB+ RAM 4 GB recommended
Storage Media files; add a data disk for large libraries
A Plex account Free at plex.tv

Part 1 — Install Plex Media Server {#part-1}

ssh ubuntu@YOUR_SERVER_IP
sudo apt update && sudo apt upgrade -y

# Download the latest Plex package
# Check https://www.plex.tv/media-server-downloads/?cat=computer&plat=linux for latest URL
wget https://downloads.plex.tv/plex-media-server-new/1.41.3.9292-a7c6edb2d/debian/plexmediaserver_1.41.3.9292-a7c6edb2d_amd64.deb

# Install
sudo dpkg -i plexmediaserver_*.deb

# Start and enable
sudo systemctl enable plexmediaserver
sudo systemctl start plexmediaserver

# Verify
sudo systemctl status plexmediaserver

Plex runs on port 32400.


Part 2 — Initial Setup via SSH Tunnel {#part-2}

Plex's initial setup requires the browser to be on the same local network as the server. Since your server is in the cloud, create an SSH tunnel:

On your local machine:

ssh -L 8888:localhost:32400 ubuntu@YOUR_SERVER_IP -N

This creates a local port 8888 that tunnels to Plex on the server.

Open your browser and go to: http://localhost:8888/web

You'll see the Plex welcome screen:

  1. Sign in with your Plex account
  2. Give the server a name
  3. Click Got It to proceed

The server is now claimed to your Plex account. Close the SSH tunnel after setup is complete.


Part 3 — Configure Nginx Reverse Proxy {#part-3}

sudo apt install -y nginx
sudo nano /etc/nginx/sites-available/plex
server {
    listen 80;
    server_name plex.yourdomain.com;

    # Plex requires large upload limits for metadata and media
    client_max_body_size 100m;

    location / {
        proxy_pass http://127.0.0.1:32400;
        proxy_http_version 1.1;

        # WebSocket support (Plex uses WebSockets for sync)
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection 'upgrade';

        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_set_header X-Plex-Device-Name $proxy_host;

        # Required for Plex to work correctly behind proxy
        proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
        proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
        proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;

        proxy_buffering off;
        proxy_read_timeout 300s;
    }
}
sudo ln -s /etc/nginx/sites-available/plex /etc/nginx/sites-enabled/
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enable
sudo nginx -t && sudo systemctl reload nginx

Part 4 — Enable HTTPS {#part-4}

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d plex.yourdomain.com

After HTTPS is configured, tell Plex to use the custom domain:

  1. Go to https://plex.yourdomain.com/web
  2. Settings → Remote Access
  3. Add your custom server access URL: https://plex.yourdomain.com

Part 5 — Add Media Libraries {#part-5}

  1. In Plex Web: Settings → Libraries → Add Library
  2. Choose type: Movies, TV Shows, Music, Photos
  3. Add folder path: /media/movies (or wherever your files are)
  4. Click Add Library

Plex scans the folder and fetches metadata automatically.

Media directory setup:

sudo mkdir -p /media/{movies,tvshows,music}
sudo chown -R plex:plex /media
# Or if keeping as ubuntu-owned:
sudo chown -R ubuntu:ubuntu /media

Part 6 — Upload Media {#part-6}

# SCP from local
scp -r ~/Movies/ ubuntu@YOUR_SERVER_IP:/media/movies/

# rsync (better for large libraries)
rsync -avzP ~/Movies/ ubuntu@YOUR_SERVER_IP:/media/movies/

Naming conventions for Plex:

/media/movies/
  ├── The Matrix (1999)/
  │   └── The Matrix (1999).mkv
  └── Interstellar (2014)/
      └── Interstellar (2014).mp4

/media/tvshows/
  └── The Office (US)/
      ├── Season 01/
      │   ├── The Office S01E01.mkv
      │   └── The Office S01E02.mkv

Part 7 — Plex Pass Features {#part-7}

The free Plex tier covers local streaming well. Plex Pass ($5/month or $120 lifetime) adds:

  • Remote streaming without relay through Plex servers
  • Hardware transcoding (Intel/NVIDIA/AMD GPU support)
  • Mobile sync — download media for offline viewing
  • Lyrics for music
  • Live TV + DVR with compatible tuners

For a self-hosted VPS scenario, the most valuable Plex Pass feature is hardware transcoding — allowing higher-quality streams without maxing out the CPU.


Part 8 — Backups {#part-8}

Plex stores metadata, watch history, and settings in its data directory:

# Default Plex data location on Linux
PLEX_DATA="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server"

# Backup metadata database
sudo tar czf plex_backup_$(date +%Y%m%d).tar.gz "$PLEX_DATA"

Note: This only backs up the Plex metadata — not your actual media files. Back up your /media directory separately.


The Gotcha: Initial Setup Requires Local Network Access {#gotcha}

Plex's claim process requires the browser to appear to be on the same network as the server. A fresh install accessed via http://SERVER_IP:32400/web from a remote machine shows a "Plex is not accessible" error, or requires a special claim token.

Fix: SSH tunnel (covered in Part 2).

After the initial setup is complete, you can access the web interface from anywhere via your domain.

If you need to re-run setup (e.g., after a fresh install):

# Stop Plex, delete the claim, restart
sudo systemctl stop plexmediaserver
# Delete Preferences.xml (contains the server claim)
sudo rm "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"
sudo systemctl start plexmediaserver
# Set up the SSH tunnel and claim again

Maintenance Commands {#maintenance}

# Update Plex
wget https://downloads.plex.tv/plex-media-server-new/LATEST/debian/plexmediaserver_LATEST_amd64.deb
sudo dpkg -i plexmediaserver_*.deb
sudo systemctl restart plexmediaserver

# View logs
sudo journalctl -u plexmediaserver -f

# Check service status
sudo systemctl status plexmediaserver

# Force library scan (via Plex API)
curl -X GET "http://localhost:32400/library/sections/all/refresh?X-Plex-Token=YOUR_TOKEN"

Troubleshooting {#troubleshooting}

Issue Likely Cause Fix
Connection refused Service not running or wrong port Check systemctl status SERVICE and verify firewall rules
Permission denied Wrong file ownership or permissions Check file ownership with ls -la and use chown/chmod to fix
502 Bad Gateway Backend service not running Restart the backend service; check logs with journalctl -u SERVICE
SSL certificate error Certificate expired or domain mismatch Run sudo certbot renew and verify domain DNS points to server IP
Service not starting Config error or missing dependency Check logs with journalctl -u SERVICE -n 50 for specific error
Out of disk space Logs or data accumulation Run df -h to identify usage; clean logs or attach CBS storage
High memory usage Too many processes or memory leak Check with htop; consider upgrading instance plan if consistently high
Firewall blocking traffic Port not open in UFW or Lighthouse console Open port in Lighthouse console firewall AND sudo ufw allow PORT

Frequently Asked Questions {#faq}

What video formats does Plex support for streaming?
Modern media servers support most common formats. Direct Play (native format support by client) is preferred over transcoding. H.264 video in MKV or MP4 containers has the widest client support.

What's the difference between Direct Play and Transcoding?
Direct Play streams the original file to the client, requiring no server CPU. Transcoding converts the video in real-time to a compatible format, requiring significant server CPU.

How much bandwidth do I need for video streaming?
Blu-ray quality: 25–40 Mbps. 1080p: 8–25 Mbps. 720p: 3–8 Mbps. Lighthouse bandwidth packages support these rates. For multiple simultaneous streams, multiply accordingly.

How do I add media files to the server?
Upload via SCP/SFTP from your local machine, rsync from a NAS, or download directly on the server. The guide covers the recommended directory structure for automatic library scanning.

How do I access my media library from outside my home network?
Your media server runs on a cloud VPS with a public IP — it's accessible from anywhere. Set up HTTPS (covered in the guide) and use the appropriate client app or web interface.

Stream your library today:
👉 Tencent Cloud Lighthouse — High-bandwidth VPS for Plex
👉 View current pricing and promotions
👉 Explore all active deals and offers