--- title: "How to Install Plex Media Server on Ubuntu 24.04" description: "Install Plex Media Server on Ubuntu 24.04, claim it through an SSH tunnel, organize your libraries, enable remote access and schedule reliable backups." category: "Media and Streaming Servers" language: en source: https://cubepath.com/docs/media-and-streaming-servers/plex-media-server-installation-on-linux updated: 2026-09-25 --- # How to Install Plex Media Server on Ubuntu 24.04 Plex Media Server organizes your movies, TV shows, music and photos, fetches artwork and metadata, and streams everything to the Plex apps on phones, smart TVs and browsers. In this tutorial you will install Plex Media Server on a headless Ubuntu 24.04 server, claim it with your Plex account through an SSH tunnel, set up libraries with correct permissions, enable remote access and configure backups of the Plex database. ## Prerequisites To follow this guide you need: - A server running Ubuntu 24.04 LTS (x86_64), for example a CubePath VPS, with at least 2 GB of RAM. Use 4 GB or more if you expect clients to transcode. - A non-root user with `sudo` privileges and UFW enabled. - A free Plex account created at `plex.tv`. - Enough disk space for your media, ideally on a separate volume from the operating system. Hardware-accelerated transcoding (Step 6) additionally requires an active Plex Pass subscription and a server with a supported GPU. ## Step 1 - Installing Plex Media Server Plex is proprietary and not part of the Ubuntu archive. Plex publishes a `.deb` package for Ubuntu on its downloads page. On your computer, open `https://www.plex.tv/media-server-downloads/`, choose **Plex Media Server**, platform **Linux**, and copy the link for the **Ubuntu (16.04+) / Debian (8+) - Intel/AMD 64-bit** package. Then, on the server, download it using that link in place of `package_url`: ```bash cd /tmp wget -O plexmediaserver.deb "package_url" ``` Install it with `apt`, which also resolves any dependencies: ```bash sudo apt install -y ./plexmediaserver.deb ``` The package creates a `plex` system user and the `plexmediaserver` systemd service. Enable it and check that it is running: ```bash sudo systemctl enable --now plexmediaserver systemctl status plexmediaserver --no-pager ``` ```output ● plexmediaserver.service - Plex Media Server Loaded: loaded (/usr/lib/systemd/system/plexmediaserver.service; enabled; preset: enabled) Active: active (running) since ... ``` Plex listens on port `32400`. Confirm it answers locally: ```bash curl -s http://localhost:32400/identity ``` ```output ``` `claimed="0"` means the server is not yet linked to a Plex account. You will fix that in Step 3. > Note: To keep Plex updated with `apt upgrade`, add the Plex apt repository following the instructions in Plex's support article about Linux updates. Otherwise, repeat this step with a newer package when an update is released. ## Step 2 - Preparing the media directories Plex runs as the `plex` user, which needs read access to your files. Keep your own user as owner and give the `plex` group read access: ```bash sudo mkdir -p /srv/media/{movies,shows,music} sudo chown -R "$USER":plex /srv/media sudo chmod -R u=rwX,g=rX,o= /srv/media sudo find /srv/media -type d -exec chmod g+s {} + ``` The setgid bit on the directories makes new files inherit the `plex` group. Verify access as the `plex` user: ```bash sudo -u plex ls /srv/media ``` ```output movies music shows ``` Plex matches titles by name, so use its naming scheme when you upload media: ```text /srv/media/movies/The Dark Knight (2008)/The Dark Knight (2008).mkv /srv/media/shows/Breaking Bad/Season 01/Breaking Bad - s01e01.mkv /srv/media/music/Artist Name/Album Name/01 - Track Name.flac ``` ## Step 3 - Claiming the server through an SSH tunnel A new Plex server can only be claimed from the same machine or local network. On a remote server, an SSH tunnel makes your browser look local. Run this on your computer: ```bash ssh -L 32400:localhost:32400 your_user@your_server_ip ``` Keep the session open and browse to `http://localhost:32400/web`. Sign in with your Plex account, give the server a name and continue through the setup screens. When asked to add libraries: 1. Click **Add Library** and choose the type (Movies, TV Shows, Music). 2. Click **Browse for media folder** and select the matching directory, such as `/srv/media/movies`. 3. Click **Add Library**. Plex starts scanning immediately. Back on the server, confirm the claim: ```bash curl -s http://localhost:32400/identity | grep -o 'claimed="[01]"' ``` ```output claimed="1" ``` ## Step 4 - Enabling remote access With remote access, Plex apps outside your network connect directly to your server on port `32400`. Open the port in UFW: ```bash sudo ufw allow 32400/tcp ``` In the web app, open **Settings > Remote Access** (under your server's settings), tick **Manually specify public port**, enter `32400` and click **Enable Remote Access** or **Retry**. After a few seconds the page should show a green **Fully accessible outside your network** status. Plex secures remote connections with its own certificates on `*.plex.direct` hostnames, so you do not need a reverse proxy. Leave **Settings > Network > Secure connections** set to **Preferred** or **Required**. You can now close the SSH tunnel. From now on, manage the server at `https://app.plex.tv` with your Plex account. ## Step 5 - Tuning transcoding Transcoding happens when a client cannot play a file's codec, bitrate or subtitles directly. On a CPU-only server it is the main source of load, so the goal is to transcode as little as possible: - Prefer H.264 video with AAC or AC3 audio in MP4 or MKV containers, which most clients play directly. - Use text subtitles (SRT) instead of image-based ones (PGS), which force video transcoding when burned in. Check how many CPU threads you have: ```bash nproc ``` A single 1080p software transcode typically needs about 2 CPU threads. In **Settings > Transcoder**, set **Maximum simultaneous video transcode** to a value your server can sustain (for example `2` on a 4 vCPU VPS), and leave **Transcoder quality** on **Automatic**. Transcoding writes temporary files to the Plex data directory by default. If you have a faster or larger disk, create a directory for it and point **Transcoder temporary directory** at it: ```bash sudo mkdir -p /srv/plex-transcode sudo chown plex:plex /srv/plex-transcode ``` ## Step 6 - Enabling hardware acceleration (optional) With Plex Pass and an Intel GPU (Quick Sync), Plex can offload transcoding to the GPU. First check that a render device is present: ```bash ls -l /dev/dri ``` ```output crw-rw---- 1 root video 226, 0 ... card0 crw-rw---- 1 root render 226, 128 ... renderD128 ``` Add the `plex` user to the `render` and `video` groups and restart the service: ```bash sudo usermod -aG render,video plex sudo systemctl restart plexmediaserver ``` In **Settings > Transcoder**, enable **Use hardware acceleration when available** and **Use hardware-accelerated video encoding**. Start a stream that needs transcoding and open the dashboard (**Activity > Dashboard**): the stream should show `(hw)` next to the transcode status. For NVIDIA cards, install the proprietary driver recommended by `ubuntu-drivers devices`, reboot, and confirm the GPU with `nvidia-smi` before enabling the same settings. ## Step 7 - Backing up the Plex database The Plex database, watch history and metadata live in: ```text /var/lib/plexmediaserver/Library/Application Support/Plex Media Server ``` Plex already creates periodic copies of its database. Confirm that **Settings > Scheduled Tasks > Backup database every three days** is enabled. Those copies stay on the same disk, so also keep an off-server archive. Create a backup script that stops Plex briefly so the database is consistent, archives everything except caches, and deletes archives older than 30 days: ```bash sudo nano /usr/local/bin/plex-backup ``` ```bash #!/usr/bin/env bash set -euo pipefail PLEX_DIR="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server" BACKUP_DIR="/var/backups/plex" ARCHIVE="${BACKUP_DIR}/plex-$(date +%F).tar.gz" mkdir -p "$BACKUP_DIR" systemctl stop plexmediaserver trap 'systemctl start plexmediaserver' EXIT tar -czf "$ARCHIVE" \ --exclude="Cache" \ --exclude="Codecs" \ --exclude="Crash Reports" \ --exclude="Diagnostics" \ --exclude="Logs" \ -C "$(dirname "$PLEX_DIR")" "$(basename "$PLEX_DIR")" find "$BACKUP_DIR" -name 'plex-*.tar.gz' -mtime +30 -delete ``` The `trap` restarts Plex even if `tar` fails. Make the script executable and run it once: ```bash sudo chmod 755 /usr/local/bin/plex-backup sudo /usr/local/bin/plex-backup ls -lh /var/backups/plex ``` ```output -rw-r--r-- 1 root root 312M ... plex-2026-01-15.tar.gz ``` Schedule it every Sunday at 04:00 with root's crontab: ```bash sudo crontab -e ``` ```text 0 4 * * 0 /usr/local/bin/plex-backup ``` Copy `/var/backups/plex` to another server or object storage with a tool such as `rsync` or `rclone`, because a backup on the same disk does not protect against disk loss. ## Troubleshooting **The setup page says no server was found.** You are probably not using the SSH tunnel, or the tunnel was opened to the wrong port. Reconnect with `ssh -L 32400:localhost:32400 ...` and open `http://localhost:32400/web`, not the server's public IP. **Libraries are empty.** Check that `sudo -u plex ls /srv/media/movies` works and that files follow the naming scheme. Then use **Scan Library Files** from the library's menu. **Remote access shows as not available.** Verify `sudo ufw status` includes `32400/tcp` and that the public port in **Settings > Remote Access** is `32400`. The server logs are in the `Logs` subdirectory of the Plex data directory; `Plex Media Server.log` records the reachability checks. ## Conclusion Plex Media Server is now running on Ubuntu 24.04 as a systemd service, claimed to your account, serving organized libraries with remote access and a weekly backup. As next steps, invite family members with **Settings > Manage Library Access**, move media to a dedicated block storage volume as your library grows, and sync the backup archives off the server.