# Plex

Plex is a media player system and software suite consisting of many player applications for 10-foot user interfaces and an associated media server that organizes personal media stored on local devices. Integrated Plex Channels provide users with access to a growing number of online content providers such as YouTube, Vimeo, TEDTalks, and CNN among others. Plex also provides integration for cloud services including Dropbox, Box, Google Drive, Copy and Bitcasa.

Plex for Linux is split into a closed-source server Plex Media Server, and an open-source client Plex Home Theater, a fork of the popular Kodi project.

## Plex Media Server (PMS)

### Installation

Install the plex-media-serverAUR package, or the plex-media-server-plexpassAUR package if you have a Plex Pass.

### Setup

Enable and start `plexmediaserver.service`.

To begin configuring PMS, browse to `http://localhost:32400/web/`.

To configure PMS remotely, you must first create an SSH tunnel (setup can only be done from `localhost`)

`ssh ip.address.of.server -L 8888:localhost:32400`

and then browse to `http://localhost:8888/web/`.

### Plugins

PMS can be expanded with additional plugins. For example, PMS can be used as an IPTV client with the IPTV plugin.

Plugins can be installed inside `$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Plug-ins`.

### Security

It is recommended to store your media files outside of your home directory, as making it accessible to PMS would mean lowering its security. Having a separate `/media` or `/mnt/media` partition is a good setup for use with PMS.

You can further increase security via systemd, by creating a `/etc/systemd/system/plexmediaserver.service.d/restrict.conf` file containing the following:

    [Service]
    ReadOnlyDirectories=/
    ReadWriteDirectories=/var/lib/plex /tmp

Note: Those mechanisms are currently limited, see DeveloperWiki:Security#ReadOnly/ReadWrite. For instance, ReadOnlyDirectories do not apply to any submount, you have to list them as well.

### Resource Management

Originally, PMS used ulimit to limit its allocated resources, however this is not compatible with running as a regular user. Instead, you can now set a maximum amount of memory via, again, systemd. For example, you can add:

    MemoryLimit=4G

to the file mentioned above.

### Network

Note: PMS supports both IPv4 and IPv6. This section only assumes the use of IPv4.

PMS and its DLNA server require several ports to be open:

- Plex Media Server: TCP 32400
- Plex DLNA Server: TCP 32469, UDP 1900
- Network Discovery: UDP 32410, 32412, 32413, 32414
- Bonjour/Avahi Network Discovery (legacy): UDP 5353

A short example with iptables:

    # iptables -A INPUT -p tcp -m multiport --dports 32400,32469 -j ACCEPT
    # iptables -A INPUT -p udp -m multiport --dports 1900,32410,32412,32413,32414 -j ACCEPT

### Remote access through vpn

#### Requirements

If you share your libraries with some friends, but want the data to go through your vpn connection, you will need two things:

- A vpn provider that allows static port forwarding
- Remote Access enabled on your plex server settings

#### How to

1. Go to your vpn provider settings and ask for a port. (We're going to assume ours gave us the port 11652)
2. Then add the following command to your boot sequence (rc.local for example)
     `# iptables -t nat -A PREROUTING -i tun0 -p tcp --dport 11652 -j REDIRECT --to-ports 32400`
     (We're going to assume you're using the tun0 interface for openvpn)
3. Finally, go to your plex server settings, enable advanced settings and define the custom port at 11652

Warning: Don't forget to replace the 11652 example port with yours!

### Troubleshooting

This article or section needs expansion.

Reason: Look if journalctl can be made equivalent with `SYSTEMD_LOG_LEVEL=debug`, currently appears unreliable, see User talk:Alucryd#Plex (Discuss in Talk:Plex#)

Logs are located in:

    $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR/Plex Media Server/Logs

In case there are no logs or they are not helpful, you might want to launch PMS manually to get some terminal output:

    sudo -u plex /usr/bin/bash
    source /etc/conf.d/plexmediaserver
    export LD_LIBRARY_PATH=/opt/plexmediaserver
    /opt/plexmediaserver/Plex\ Media\ Server

## Plex Home Theater (PHT)

### Installation

Install the openphtAUR package.

Plex Home Theater can be launched by running `plexhometheater.sh` from your terminal.

## Kodi and PleXBMC

With the PleXBMC add-on, Kodi can be used as a replacement for PHT.

### Installation

Install the kodi package, then follow the instructions over here.

Category:

- Streaming

Hidden category:

- Pages or sections flagged with Template:Expansion