웹사이트 검색

Ubuntu 20.04에 Plex Media Server 설치


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 우분투 20.04(Focal Fossa)
  • 우분투 16.04(Xenial Xerus)

이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. Plex 미디어 서버 설치
  4. Plex 미디어 서버 저장소 활성화\n
  5. Plex용 Nginx 구성
  6. Plex 미디어 서버 액세스
  7. Lets Encrypt SSL을 사용한 보안 Plex\n
  8. 결론

Plex는 비디오, 음악 및 사진을 구성하고 어디서나 원격 장치로 스트리밍하는 데 사용할 수 있는 강력하고 기능이 풍부한 미디어 스트리밍 서버입니다. Linux, Windows, FreeBSD, macOS 등 많은 운영 체제를 지원합니다. Plex 미디어 클라이언트를 사용하여 스마트 TV, 스마트폰 및 스트리밍 박스에서 Plex 서버에 저장된 미디어에 액세스할 수 있습니다.

Plex에는 많은 기능이 있으며 그 중 일부는 아래에 나열되어 있습니다. gpt-ad-howtoforge_com-medrectangle-3-0;var ffid=1;var alS=1021%1000;var container=document.getElementById(slotId);container.style.width=100%;var ins=document.createElement( ins);ins.id=slotId+-asloaded;ins.className=adsbygoogle ezasloaded;ins.dataset.adClient=pid;ins.dataset.adChannel=cid;if(ffid==2){ins.dataset.fullWidthResponsive=true; }

  • 라이브 TV 및 DVR.
  • 모바일 동기화.\n
  • 클라우드 동기화.\n
  • 프리미엄 음악 기능.\n
  • 프리미엄 사진 라이브러리.\n
  • 하드웨어 가속 스트리밍.\n
  • 자녀 보호.\n
  • 카메라 업로드.
  • 대역폭 및 트랜스코딩 제한.\n

이 튜토리얼에서는 Ubuntu 20.04 서버에서 Nginx를 리버스 프록시로 사용하여 Plex 미디어 서버를 설치하는 방법을 설명합니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 루트 암호가 구성되었습니다.\n

시작하기

먼저 시스템 패키지를 최신 버전으로 업데이트해야 합니다. 다음 명령으로 업데이트할 수 있습니다.

apt-get update -y

패키지가 업데이트되면 다음 단계로 진행할 수 있습니다.

Plex 미디어 서버 설치

먼저 Plex 공식 웹사이트에서 최신 버전의 Plex 미디어 서버를 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.

wget https://downloads.plex.tv/plex-media-server-new/1.20.1.3252-a78fef9a9/debian/plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb

Plex 미디어 서버 패키지가 다운로드되면 다음 명령을 사용하여 설치할 수 있습니다.

dpkg -i plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb

Plex 미디어 서버가 설치되면 Plex 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 시 시작되도록 활성화합니다.

systemctl start plexmediaserver
systemctl enable plexmediaserver

다음으로 다음 명령을 사용하여 Plex 서비스의 상태를 확인할 수 있습니다.

systemctl status plexmediaserver

다음 출력이 표시되어야 합니다.

? plexmediaserver.service - Plex Media Server
     Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-09-05 06:48:06 UTC; 17s ago
    Process: 38369 ExecStartPre=/bin/sh -c /usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERV>
   Main PID: 38371 (Plex Media Serv)
      Tasks: 120 (limit: 2353)
     Memory: 215.0M
     CGroup: /system.slice/plexmediaserver.service
             ??38371 /usr/lib/plexmediaserver/Plex Media Server
             ??38405 Plex Plug-in [com.plexapp.system] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Contents/Resourc>
             ??38451 /usr/lib/plexmediaserver/Plex Tuner Service /usr/lib/plexmediaserver/Resources/Tuner/Private /usr/lib/plexmediaserver/Res>
             ??38474 Plex Plug-in [com.plexapp.agents.plexthememusic] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/C>
             ??38477 Plex Plug-in [com.plexapp.agents.themoviedb] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Conte>
             ??38533 Plex Plug-in [org.musicbrainz.agents.music] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Conten>
             ??38544 Plex Plug-in [com.plexapp.agents.thetvdb] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Contents>
             ??38638 Plex Plug-in [com.plexapp.agents.opensubtitles] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Co>
             ??38710 Plex Plug-in [com.plexapp.agents.fanarttv] /usr/lib/plexmediaserver/Resources/Plug-ins-a78fef9a9/Framework.bundle/Content>

Sep 05 06:48:06 ubunt4 systemd[1]: Starting Plex Media Server...
Sep 05 06:48:06 ubunt4 systemd[1]: Started Plex Media Server.

이 시점에서 Plex 미디어 서버가 시작되고 포트 32400에서 수신 대기합니다. 다음 명령으로 확인할 수 있습니다.

ss -lnpt | grep Plex

다음 출력이 표시되어야 합니다.

LISTEN    0         128              127.0.0.1:39851            0.0.0.0:*        users:(("Plex Script Hos",pid=38739,fd=4))                                     
LISTEN    0         128              127.0.0.1:46031            0.0.0.0:*        users:(("Plex Script Hos",pid=38779,fd=4))                                     
LISTEN    0         1024             127.0.0.1:32401            0.0.0.0:*        users:(("Plex Media Serv",pid=38371,fd=61))                                    
LISTEN    0         128              127.0.0.1:44661            0.0.0.0:*        users:(("Plex Script Hos",pid=38533,fd=4))                                     
LISTEN    0         128              127.0.0.1:32600            0.0.0.0:*        users:(("Plex Tuner Serv",pid=38451,fd=13))                                    
LISTEN    0         128              127.0.0.1:36637            0.0.0.0:*        users:(("Plex Script Hos",pid=38544,fd=4))                                     
LISTEN    0         128              127.0.0.1:42973            0.0.0.0:*        users:(("Plex Script Hos",pid=38405,fd=10))                                    
LISTEN    0         128              127.0.0.1:38467            0.0.0.0:*        users:(("Plex Script Hos",pid=38824,fd=4))                                     
LISTEN    0         128              127.0.0.1:40035            0.0.0.0:*        users:(("Plex Script Hos",pid=38477,fd=4))                                     
LISTEN    0         1024                     *:32400                  *:*        users:(("Plex Media Serv",pid=38371,fd=60))    

완료되면 다음 단계로 진행할 수 있습니다.

Plex 미디어 서버 리포지토리 활성화

기본적으로 Plex 미디어 서버 리포지토리는 APT에서 비활성화되어 있습니다. 따라서 APT 명령을 사용하여 Plex 미디어 서버를 업데이트할 수 있도록 활성화하는 것이 좋습니다. 다음 파일을 편집하여 활성화할 수 있습니다.

nano /etc/apt/sources.list.d/plexmediaserver.list

다음 줄의 주석 처리를 제거하십시오.

deb https://downloads.plex.tv/repo/deb/ public main

파일을 저장하고 닫은 후 다음 명령을 사용하여 Plex GPG 키를 추가합니다.

wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | apt-key add -

이제 다음 명령으로 리포지토리를 업데이트하여 변경 사항을 적용합니다.

apt-get update -y

리포지토리가 업데이트되면 다음 단계를 진행할 수 있습니다.

Plex용 Nginx 구성

다음으로 Nginx를 Plex용 리버스 프록시로 설치하고 구성하는 것이 좋습니다. 따라서 포트 80을 사용하여 Plex 미디어 서버에 액세스할 수 있습니다.

먼저 다음 명령을 사용하여 Nginx 웹 서버를 설치합니다.

apt-get install nginx -y

Nginx 웹 서버가 설치되면 다음 명령을 사용하여 새 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/sites-available/plex.conf

다음 줄을 추가합니다.

upstream plex_backend {
        server 127.0.0.1:32400;
        keepalive 32;
}

server {
        listen 80;
        server_name plex.example.com;

        send_timeout 100m; #Some players don't reopen a socket and playback stops totally instead of resuming after an extended pause (e.g. Ch$

       	#Plex has A LOT of javascript, xml and html. This helps a lot, but if it causes playback issues with devices turn it off. (Haven't enc$
        gzip on;
        gzip_vary on;
        gzip_min_length 1000;
        gzip_proxied any;
        gzip_types 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 1MB, which breaks Camera Upload feature from the phones.
       	#Increasing the limit fixes the issue. Anyhow, if 4K videos are expected to be uploaded, the size might need to be increased even more
        client_max_body_size 100M;

       	#Forward real ip and host to 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 off send to the client as soon as the data is received from Plex.
        proxy_redirect off;
        proxy_buffering off;

        location / {
                proxy_pass http://plex_backend;
        }
}

파일을 저장하고 닫은 후 다음 명령을 사용하여 구문 오류가 있는지 Nginx를 확인합니다.

nginx -t

다음과 같은 결과가 표시되어야 합니다.

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

다음으로 다음 명령을 사용하여 Nginx 가상 호스트 구성 파일을 활성화합니다.

ln -s nano /etc/nginx/sites-available/plex.conf /etc/nginx/sites-enabled/

마지막으로 Nginx 서비스를 다시 시작하여 구성 변경 사항을 적용합니다.

systemctl restart nginx

이제 다음 명령을 사용하여 Nginx 상태를 확인할 수 있습니다.

systemctl status nginx

다음과 같은 결과가 표시되어야 합니다.

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-09-05 06:57:20 UTC; 1min 47s ago
       Docs: man:nginx(8)
    Process: 40059 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 40070 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 40072 (nginx)
      Tasks: 3 (limit: 2353)
     Memory: 3.6M
     CGroup: /system.slice/nginx.service
             ??40072 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??40073 nginx: worker process
             ??40074 nginx: worker process

Sep 05 06:57:20 ubunt4 systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 05 06:57:20 ubunt4 systemd[1]: Started A high performance web server and a reverse proxy server.

완료되면 다음 단계로 진행할 수 있습니다.

Plex 미디어 서버에 액세스

이 시점에서 Plex 미디어 서비스가 설치되고 Nginx로 구성됩니다. 이제 웹 브라우저를 열고 URL http://plex.example.com을 사용하여 Plex 미디어 서버에 액세스합니다. 다음 페이지가 표시됩니다.

이제 Google 또는 Facebook 계정으로 로그인하십시오. 다음 페이지에 Plex 미디어 서버 대시보드가 표시되어야 합니다.

Lets Encrypt SSL을 사용한 Secure Plex

다음으로 Lets Encrypt SSL로 Plex를 보호하는 것이 좋습니다. 먼저 SSL을 설치하고 관리하려면 서버에 Certbot Lets Encrypt 클라이언트를 설치해야 합니다. 다음 명령으로 설치할 수 있습니다.

apt-get install python3-certbot-nginx -y

Certbot을 설치한 후 다음 명령을 실행하여 도메인에 Lets Encrypt SSL을 설치합니다.

certbot --nginx -d plex.example.com

유효한 이메일 주소를 제공하고 아래와 같이 서비스 약관에 동의하라는 메시지가 표시됩니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for plex.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/plex.conf

다음으로, 아래와 같이 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2를 입력하고 Enter 키를 눌러 설치를 마칩니다. 다음 출력이 표시되어야 합니다.

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/plex.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://plex.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=plex.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/plex.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/plex.example.com/privkey.pem
   Your cert will expire on 2020-10-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

이제 URL https://plex.example.com을 사용하여 Plex 미디어 서버에 안전하게 액세스할 수 있습니다.

결론

축하합니다! Ubuntu 20.04 서버에 역방향 프록시로 Nginx와 함께 Plex 미디어 서버를 성공적으로 설치했습니다. 이제 미디어, 음악 및 사진을 업로드하고 스마트폰, TV 또는 기타 스트리밍 박스에서 액세스할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.