Ampacheは、独自の音楽ストリーミングサーバーをホストできる、無料のオープンソースのWebベースのソフトウェアです。 Ampacheを使用すると、インターネット経由で音楽やビデオにアクセスできます。 Webブラウザまたは任意のメディアストリーミングクライアントを介して、音楽を表示、編集、および再生できます。
機能
- 強力なAPIとあらゆるクライアントへのストリーミング
- 柔軟なカタログとカスタマイズ
- 最新のHTML5Webプレーヤー
- MySQL、LDAP、HTTP、PAMなどのさまざまな認証方法をサポートします
- サブソニッククライアントとの互換性
このチュートリアルでは、Ubuntu20.04でAmpache音楽ストリーミングサーバーをセットアップする方法を学習します。
- Ubuntu20.04を実行しているサーバー。
- ルートパスワードがサーバーに設定されています。
開始する前に、システムのパッケージを最新バージョンに更新することをお勧めします。次のコマンドを使用して更新できます:
apt-get update -y
apt-get upgrade -y
すべてのパッケージが更新されたら、システムを再起動して変更を適用します。
LAMPサーバーをインストールする
Ampacheは、PHPで記述されたWebサーバー上で実行され、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のrootパスワードを入力し、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
ダウンロードが完了したら、ダウンロードしたファイルをApacheWebルートディレクトリに解凍します。
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
終了したら、次のステップに進むことができます。
ApacheをAmpache用に設定
次に、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がインストールおよび構成されています。これで、次のステップに進むことができます。
Let'sEncryptSSLを使用してAmpacheWebサイトを保護することをお勧めします。
まず、Certbotクライアントをインストールして、Webサイト用のLet'sEncryptSSLをダウンロードしてインストールします。
apt-get install certbot python3-certbot-apache -y
インストールしたら、次のコマンドを実行して、WebサイトにLet'sEncryptSSLをインストールします。
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): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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
次に、次のコマンドを使用して、Let'sEncrypt証明書の自動更新をテストします。
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.)
これで、AmpacheWebサイトがLet'sEncryptSSLで保護されました。次に、Webブラウザーを開き、URLhttps://ampache.linuxbuz.comを入力します。次のページにリダイレクトされます:
言語を選択して、開始をクリックします 構成 ボタン。次のページが表示されます:
必要なPHP拡張機能がすべてインストールされていることを確認してから、続行をクリックします。 ボタン。次のページが表示されます:
データベースの詳細を入力し、[データベースの作成]をオフにし、[テーブルの作成]をオンにし、[データベースユーザーの作成]をオフにして、[挿入]をクリックします。 データベース ボタン。次のページが表示されます:
データベースの詳細を入力し、ffmpegを選択して、作成をクリックします。 構成 。次のページが表示されます:
管理者のユーザー名とパスワードを入力し、作成をクリックします アカウント ボタン。次のページが表示されます:
更新をクリックします 今 ボタンをクリックして、必要なすべてのパッケージを更新します。次のページが表示されます:
メインページに戻るをクリックします リンク。次のページが表示されます:
管理者のユーザー名とパスワードを入力し、ログインをクリックします ボタン。次のページにAmpacheダッシュボードが表示されます。
おめでとう!これで、Ubuntu20.04サーバーにAmpacheが正常にインストールされて保護されました。これで、新しいカタログを作成し、音楽をアップロードして、インターネット経由で再生できます。