قالب وردپرس درنا توس
Home / How To / How to install Plex Media Server on CentOS 8

How to install Plex Media Server on CentOS 8



Plex is a free, open source and full-featured media server that lets you stream your photos, video and audio files on your PC, tablet, phone from anywhere in the world. Plex supports most operating systems including Linux, Windows, Mac and FreeBSD. Plex also supports several plugins that let you watch content from Comedy Central and MTV.

Plex is a client server media player system. You simply install the Plex server on the server where you keep your media, and then install a Plex application of your phone, tablet or other devices to access your media over the Internet.

Features Support for multiple users. View movies / TV show recommendations. Create a playlist for your favorite music and movies. Synchronize and access media files for offline use. Parental controls allow you to install the Plex application on a child's device and restrict them to see only specific content. Ability to stream your local TV channels to your device and watch live TV.

In this tutorial, we will show you how to install Plex Media Server on a CentOS 8 system using Nginx as a reverse proxy.

Prerequisites [1
9659006] A server running CentOS 8 with at least 2 GB of RAM.
  • A valid domain name is pointed with your server IP.
  • A root password is configured on your server.
  • Updating the System

    First, it is recommended that you update your server with the latest version. You can update it with the following command:

      dnf update -y 

    After your server is updated, restart it to implement the changes.

    By default, the Plex media server package is not available in the CentOS 8 standard repository. So you need to create an archive for the Plex media server. You can create it with the following command:

      nano /etc/yum.repos.d/plex.repovud19659012achteAdd the following lines: 

    [Plex]
      name = Plex
    baseURL = https: //downloads.plex.tv/repo/rpm/$basearch/
    enabled = 1
    gpgkey = https: //downloads.plex.tv/plex-keys/PlexSign.key
    gpgcheck = 1
    

    Save and close the file when you are done. Then install the Plex media server with the following command:

      dnf install plex media server-y 

    When the installation is complete, restart the Plex media service and enable it after restarting the system with the following command:

      systemctl enable plex media server 
    systemctl start plex media server

    You can also verify the status of Plex media server with the following command:

      systemctl status plex media server 

    You should see the following output:

    ? plexmediaserver.service - Plex Media Server
    Loaded: loaded (/usr/lib/systemd/system/plexmediaserver.service; enabled; vendor setting: disabled)
    Active: active (running) since Mon 2020-01-06 02:45:40 EST; 41s ago
    Main PID: 1009 (Plex Media Serv)
    Details: 113 (limit: 12552)
    Memory: 268.1 M
    CGroup: /system.slice/plexmediaserver.service
    ?? 1009 / usr / lib / plex media server / Plex media server
    ?? 1033 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents/Resources/>
    ?? 1077 / usr / lib / plex media server / Plex Tuner Service / usr / lib / plex media server / Resources / Tuner / Private / usr / lib / plex media server / Resource>
    ?? 1246 Plex Plug-in [org.musicbrainz.agents.music] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents/>
    ?? 1356 Plex Plug-in [com.plexapp.agents.plexthememusic] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Cont>
    ?? 1364 Plex Plug-in [com.plexapp.agents.themoviedb] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents>
    ?? 1365 Plex Plug-in [tv.plex.agents.music] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents/Resource>
    ?? 1389 Plex Plug-in [com.plexapp.agents.thetvdb] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents/Re>
    ?? 1450 Plex Plug-in [com.plexapp.agents.imdb] /usr/lib/plexmediaserver/Resources/Plug-ins-349e9837e/Framework.bundle/Contents/Resou>
    
    06 Jan 02:45:40 plex systemd [1]: Start Plex Media Server ...
    Jan 06 02:45:40 plex systemd [1]: Started Plex Media Server.
    

    At this time, Plex media server is installed and running. You can now move on to the next step.

    Next, you need to configure firewall to allow Plex media server-specific ports. You can do this by running the following commands:

      firewall-cmd - zone = public --add-port = 32400 / tcp --permanent 
    firewall-cmd --zone = public --add-port = 32469 / tcp --permanent
    firewall-cmd - zone = public --add-port = 8324 / tcp --permanent
    firewall-cmd - zone = public --add-port = 3005 / tcp - -permanent
    firewall cmd - zone = public --add-port = 32412 / udp --permanent
    firewall-cmd - zone = public --add-port = 32413 / udp --permanent
    firewall-cmd - zone = public --add-port = 32414 / udp --permanent
    firewall-cmd --zone = public --add-port = 32410 / udp --permanent
    firewall-cmd --zone = public - -add-port = 1900 / udp --permanent
    firewall-cmd --zone = public --add-port = 5353 / udp --permanent
    firewall-cmd --zone = public --add-port = 80 / tcp --permanent

    Then reload the firewall service to implement the changes:

      firewal l-cmd - reload 

    By default, SELinux is enabled on the CentOS 8 server. So you need to configure SELinux to access Plex Media Server over the internet. You can configure SELinux with the following command:

      setsebool httpd_can_network_connect on -P 

    At this point, the Plex media server may be accessible over the Internet. You can now move on to the next step.

    You can now access the Plex media server at URL http: // your-server-ip: 32400 . You should see the following page:

     Plex Login

    Then you must register with a valid email address to use the service. After successful registration. You will be redirected to the Plex media server dashboard shown below:

     Plex Media Server Dashboard

    Setting Nginx as a Reverse Proxy

    Then you must configure an Nginx as a reverse proxy so that you can access it with domain name without specifying IP address and port number.

    To do so, first install the Nginx web server with the following command:

      dnf install nginx 

    When the installation is complete, restart the Nginx service and enable it after restarting the system with the following command:

      systemctl start nginx 
    systemctl enable nginx

    Then create an Nginx virtual host configuration file for Plex with the following command:

      nano /etc/nginx/conf.d/plex.confebrit19659012??Add the following lines: 

     upstream plex_backend {
    server 127.0.0.1:32400;
    keepalive 32;
    }
    
    server {
    listen 80;
    server name plex.example.com;
    
    send_timeout 100m; # Some players will not re-open an outlet and playback will stop completely instead of resuming after an extended pause (eg Ch $
    
    #Plex has LOTS of javascript, xml and html. This helps a lot, but if it causes playback problems with devices turn it off. (Did not encode $
    gzip på;
    gzip_vary on;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_typer text / plain text / css text / xml application / xml text / javascript application / x-javascript image / svg + xml;
    gzip_disable "MSIE [1-6] .";
    
    #Nginx default client_max_body_size is 1 MB, which breaks the camera transfer function from the phones.
    # Increasing the boundary solves the problem. However, if 4K videos are expected to be uploaded, the size may need to be increased even more
    client_max_body_size 100M;
    
    # Forward real ip and host for Plex
    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 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;
    #Websockets
    proxy_http_version 1.1;
    proxy_set_header Upgrade $ http_upgrade;
    proxy_set_header Connection "Upgrade";
    
    #Buffering of sending to client as soon as data is received from Plex.
    proxy_redirect av;
    proxy_buffering of;
    
    location / {
    proxy_pass http: // plex_backend;
    }
    }
    

    Save and close the file when you are done. Next, you must define the size of the Nginx server hash bucket. You can do this by editing the Nginx configuration file:

      nano /etc/nginx/nginx.confebrit19659012achteAdd the following line just above the last line: 

     server_names_hash_bucket_size 64;
    

    Save and close the file when you are done. Then check Nginx for syntax errors with the following command:

      nginx -t 

    You should see the following output:

     nginx: configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: The /etc/nginx/nginx.conf test configuration file is successful
    

    Finally, restart the Nginx service to implement the changes.

      systemctl restart nginx 

    To check the status of the Nginx service, run the following command:

      systemctl status nginx 

    If all is well you should get the following output:

    ? nginx.service - Nginx HTTP and reverse proxy server
    Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor setting: disabled)
    Drop-In: /usr/lib/systemd/system/nginx.service.d
    ?? php fpm.conf
    Active: active (running) since Thu 2020-01-09 05:17:27 EST; 48s ago
    Process: 1230 ExecStart = / usr / sbin / nginx (code = terminated, status = 0 / SUCCESS)
    Process: 1229 ExecStartPre = / usr / sbin / nginx-t (code = terminated, status = 0 / SUCCESS)
    Process: 1227 ExecStartPre = / usr / bin / rm -f /run/nginx.pid (code = terminated, status = 0 / SUCCESS)
    Main PID: 1232 (nginx)
    Details: 2 (limit: 5060)
    Memory: 13.1 M
    CGroup: /system.slice/nginx.service
    ?? 1232 nginx: master process / usr / sbin / nginx
    ?? 1233 nginx: worker process
    
    Jan 09 05:17:25 centos8 systemd [1]: Start nginx HTTP and reverse proxy server ...
    Jan 09 05:17:27 centos8 nginx [1229]: nginx: configuration file /etc/nginx/nginx.conf syntax is ok
    Jan 09 05:17:27 centos8 nginx [1229]: nginx: configuration file /etc/nginx/nginx.conf test is successful
    

    You can now access your Plex media server at URL http://plex.example.com .

    Conclusion

    Congratulations! you have installed the Plex media server on CentOS 8 with Nginx as a reverse proxy. You can now explore Plex Media Server for more options and set up your own media library. Then you can install the Plex application from the phone's Play Store and access your media. You can also allow your friends and family to access your photos, music and movies from a browser or a Plex application. Feel free to ask me if you have any questions.


    Source link