웹사이트 검색

Ubuntu 20.04에 Ampache 음악 스트리밍 서버를 설치하는 방법


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

  • Ubuntu 20.04(Focal Fossa)
  • Ubuntu 12.04 LTS(Precise Pangolin)

이 페이지에서

  1. 전제 조건
  2. 시작하기\n
  3. LAMP 서버 설치
  4. MariaDB 데이터베이스 구성
  5. 암파치 다운로드
  6. Apache용 Apache 구성
  7. Lets Encrypt SSL로 Ampache 보안
  8. Ampache 웹 인터페이스 액세스
  9. 결론

Ampache는 자신만의 음악 스트리밍 서버를 호스팅할 수 있는 무료 오픈 소스 웹 기반 소프트웨어입니다. Ampache를 사용하면 인터넷을 통해 음악과 비디오에 액세스할 수 있습니다. 웹 브라우저 또는 모든 미디어 스트리밍 클라이언트를 통해 음악을 보고, 편집하고, 재생할 수 있습니다.

특징

  • 강력한 API 및 모든 클라이언트로의 스트리밍\n
  • 유연한 카탈로그 및 맞춤화\n
  • 최신 HTML5 웹 플레이어\n
  • MySQL, LDAP, HTTP, PAM 등 다양한 인증 방식 지원\n
  • 모든 Subsonic 클라이언트와의 호환성\n

이 튜토리얼에서는 Ubuntu 20.04에서 Ampache 음악 스트리밍 서버를 설정하는 방법을 배웁니다.

전제 조건

  • Ubuntu 20.04를 실행하는 서버.\n
  • 서버에 루트 암호가 설정되어 있습니다.\n

시작하기

시작하기 전에 시스템 패키지를 최신 버전으로 업데이트하는 것이 좋습니다. 다음 명령을 사용하여 업데이트할 수 있습니다.

apt-get update -y
apt-get upgrade -y

모든 패키지가 업데이트되면 시스템을 다시 시작하여 변경 사항을 적용하십시오.

램프 서버 설치

Ampache는 PHP로 작성된 웹 서버에서 실행되며 MySQL/MariaDB를 사용하여 데이터를 저장합니다. 따라서 시스템에 Apache, MariaDB, PHP 및 기타 필수 PHP 확장을 설치해야 합니다. 다음 명령을 실행하여 설치할 수 있습니다.

apt-get install apache2 libapache2-mod-php php php-cli mariadb-server php-mysql php-curl php-json php-gd php-xml unzip curl git zip ffmpeg -y

모든 패키지가 설치되면 php.ini 파일을 열고 몇 가지 설정을 조정합니다.

nano /etc/php/7.4/apache2/php.ini

다음 값을 변경합니다.

upload_max_filesize = 100M
post_max_size = 100M
date.timezone = Asia/Kolkata

완료되면 파일을 저장하고 닫습니다. 그런 다음 Apache 서비스를 다시 시작하여 변경 사항을 구현합니다.

systemctl restart apache2

MariaDB 데이터베이스 구성

기본적으로 MariaDB는 보안되지 않습니다. 다음 스크립트를 실행하여 보안을 설정할 수 있습니다.

mysql_secure_installation

아래와 같이 모든 질문에 답하십시오.

Enter current password for root (enter for none): 
Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

MariaDB가 보호되면 다음 명령을 사용하여 MariaDB 셸에 로그인합니다.

mysql -u root -p

다음 명령을 사용하여 MariaDB 루트 암호를 제공하고 Ampache용 데이터베이스 및 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE ampachedb;
MariaDB [(none)]> CREATE USER 'ampache'@'localhost' IDENTIFIED BY 'password';

다음으로 다음 명령을 사용하여 Ampache 데이터베이스에 모든 권한을 부여합니다.

MariaDB [(none)]> GRANT ALL PRIVILEGES ON ampachedb.* TO 'ampache'@'localhost';

다음으로 다음 명령을 사용하여 권한을 플러시하고 MariaDB 셸을 종료합니다.

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

암파치 다운로드

다음 명령을 사용하여 최신 버전의 Ampache를 다운로드할 수 있습니다.

wget https://github.com/ampache/ampache/releases/download/4.1.1/ampache-4.1.1_all.zip

다운로드가 완료되면 다운로드한 파일을 Apache 웹 루트 디렉터리에 압축을 풉니다.

unzip ampache-4.1.1_all.zip -d /var/www/html/ampache

다음으로 Ampache 디렉토리의 소유권을 www-data로 변경합니다.

chown -R www-data:www-data /var/www/html/ampache

다음으로 디렉토리를 ampache로 변경하고 필요한 .htaccess 파일의 이름을 바꿉니다.

cd /var/www/html/ampache
mv rest/.htaccess.dist rest/.htaccess
mv play/.htaccess.dist play/.htaccess
mv channel/.htaccess.dist channel/.htaccess

다음으로 음악 파일을 저장할 디렉토리를 만들고 소유권을 www-data로 변경합니다.

mkdir -p /data/Music
chown www-data:www-data /data/Music

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

Ampache용 Apache 구성

다음으로 Ampache용 새 Apache 가상 호스트 구성 파일을 생성해야 합니다. 다음 명령으로 만들 수 있습니다.

nano /etc/apache2/sites-available/ampache.conf

다음 줄을 추가합니다.

<VirtualHost *:80>

    ServerName ampache.linuxbuz.com
    DocumentRoot /var/www/html/ampache

    <Directory /var/www/html/ampache/>
        AllowOverride All
        Require all granted
    </Directory>

    RewriteEngine on
    CustomLog /var/log/apache2/ampache.access.log common
    ErrorLog  /var/log/apache2/ampache.error.log

</VirtualHost>

완료되면 파일을 저장하고 닫습니다. 그런 다음 다음 명령을 사용하여 Apache 구성 파일에서 오류가 있는지 확인합니다.

apachectl configtest

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

Syntax OK

다음으로 다음 명령을 사용하여 Apache 가상 호스트 구성 파일 및 필수 모듈을 활성화합니다.

a2ensite ampache
a2enmod expires rewrite

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

systemctl reload apache2

이 시점에서 Ampache가 설치되고 구성됩니다. 이제 다음 단계를 진행할 수 있습니다.

Lets Encrypt SSL로 Ampache 보호

Lets Encrypt SSL로 Ampache 웹사이트를 보호하는 것이 좋습니다.

먼저 Certbot 클라이언트를 설치하여 웹사이트용 Lets Encrypt SSL을 다운로드하고 설치합니다.

apt-get install certbot python3-certbot-apache -y

설치가 완료되면 다음 명령을 실행하여 웹사이트에 Lets Encrypt SSL을 설치합니다.

certbot --apache -d ampache.linuxbuz.com

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

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
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 ampache.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/ampache-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/ampache-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/ampache-le-ssl.conf

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

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 vhost in /etc/apache2/sites-enabled/ampache.conf to ssl vhost in /etc/apache2/sites-available/ampache-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://ampache.linuxbuz.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/ampache.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/ampache.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-07-29. 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

다음으로 다음 명령을 사용하여 Lets Encrypt 인증서의 자동 갱신을 테스트합니다.

certbot renew --dry-run

테스트에 성공하면 다음과 같은 결과가 표시됩니다.

** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)

Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/ampache.linuxbuz.com/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)

Ampache 웹 인터페이스에 액세스

귀하의 Ampache 웹사이트는 이제 Lets Encrypt SSL로 보호됩니다. 그런 다음 웹 브라우저를 열고 URL https://ampache.linuxbuz.com을 입력합니다. 다음 페이지로 리디렉션됩니다.

언어를 선택하고 구성 시작 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

필요한 모든 PHP 확장이 설치되었는지 확인한 다음 계속 버튼을 클릭하십시오. 다음 페이지가 표시됩니다.

데이터베이스 세부 정보를 제공하고 데이터베이스 생성을 선택 취소하고 테이블 생성을 선택하고 데이터베이스 사용자 생성을 선택 취소하고 데이터베이스 삽입 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

데이터베이스 세부 정보를 제공하고 ffmpeg를 선택한 다음 구성 만들기를 클릭합니다. 다음 페이지가 표시됩니다.

관리자 사용자 이름, 암호를 제공하고 계정 만들기 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

지금 업데이트 버튼을 클릭하여 필요한 모든 패키지를 업데이트합니다. 다음 페이지가 표시됩니다.

기본 페이지로 돌아가기 링크를 클릭합니다. 다음 페이지가 표시됩니다.

관리자 사용자 이름, 암호를 제공하고 로그인 버튼을 클릭합니다. 다음 페이지에서 Ampache 대시보드를 볼 수 있습니다.

결론

축하합니다! Ubuntu 20.04 서버에 Ampache를 성공적으로 설치하고 보호했습니다. 이제 새 카탈로그를 만들고 음악을 업로드하고 인터넷을 통해 재생할 수 있습니다.