In one of my previous posts, I talked about Running Ubuntu/Linux on Android and there I had mentioned about setting up a media center with Plex. I assumed it to be a straight-forward process but it took me a lot of time to set it up correctly. Though, the final steps here are quick and easy to use, it took a lot of work to come to these steps. The following steps didn’t work for me:

  • Installing using Plex apt repository
  • Manually installing with the deb package from the Plex Download Page
  • Trying all configurations available on the Internet

Prerequisites

You can try other configurations, I am mentioning versions that worked for me. But because of the fragile nature of this setup, other configurations might not work

  • Xiaomi Redmi Note 5 Pro running Android 10, rooted with Magisk
  • LinuxDeploy 2.6.0-258
  • Debian > arm64 > buster

Setup Plex

curl -O https://downloads.plex.tv/plex-media-server-new/1.21.1.3876-3c3adfcb4/debian/plexmediaserver_1.21.1.3876-3c3adfcb4_arm64.deb

Extract the deb package in a directory accessible with your current user

dpkg-deb --extract plexmediaserver_1.21.1.3876-3c3adfcb4_arm64.deb /home/android/plex

plex should contain etc and usr sub-directories. We need to edit the following files

plexmediaserver.service

sudo vim plex/usr/lib/plexmediaserver/lib/plexmediaserver.service
.
.
.

## ----- Change these two paths to point to the directory in the home folder ----- 

# Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
# Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/home/android/plex/var/lib/plexmediaserver/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_HOME=/home/android/plex/usr/lib/plexmediaserver

## ----- Change these two paths to point to the directory in the home folder ----- 

# export LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib; \
# exec "/usr/lib/plexmediaserver/Plex Media Server"'
export LD_LIBRARY_PATH=/home/android/plex/usr/lib/plexmediaserver/lib; \
exec "/home/android/plex/usr/lib/plexmediaserver/Plex Media Server"'

Type=simple


## ----- Change the user and group to your user and group ----- 

# User=plex
# Group=plex
User=android
Group=android
.
.
.

plexmediaserver.init

sudo vim plex/usr/lib/plexmediaserver/lib/plexmediaserver.init

## ----- Change the user and group to your user and group ----- 
# PlexUser="plex"
PlexUser="android"


## ----- Change these two paths to point to the directory in the home folder ----- 

# PlexHome="/usr/lib/plexmediaserver"
# PlexAppSuppDir="/var/lib/plexmediaserver/Library/Application Support"
PlexHome="/home/android/plex/usr/lib/plexmediaserver"
PlexAppSuppDir="/home/android/plex/var/lib/plexmediaserver/Library/Application Support"


PlexTempDir="/tmp"
PlexStackSize=3000

.
.
.

That is all the necessary configiration needed. Plex server can be started by running the plexmediaserver.init service.

sudo ./home/android/plex/usr/lib/plexmediaserver/lib/plexmediaserver.init start

By default Plex media server runs on the port 32400, to configure Plex and add media to it, access the dashboard using http://<your-server-ip>:32400 in a web browser. You’ll be welcomed with a configuration screen from where you can login to your Plex account and add photos, movies, tv shows etc to serve from your Android Phone.

Let me know if you face any problems or find another way of setting up Plex easily.

References