GNU/Linux >> Belajar Linux >  >> Ubuntu

Cara Menginstal Server Streaming Musik Ampache di Ubuntu 20.04

Ampache adalah perangkat lunak gratis, sumber terbuka, dan berbasis web yang memungkinkan Anda meng-host server streaming musik Anda sendiri. Dengan Ampache, Anda dapat mengakses musik dan video Anda melalui internet. Anda dapat melihat, mengedit, dan memutar musik melalui browser web atau klien streaming media apa pun.

Fitur

  • API dan streaming yang andal ke klien mana pun
  • Katalog dan penyesuaian yang fleksibel
  • Pemutar Web HTML5 Modern
  • Mendukung berbagai metode otorisasi seperti MySQL, LDAP, HTTP, dan PAM
  • Kompatibilitas dengan klien Subsonik apa pun

Dalam tutorial ini, kita akan mempelajari cara mengatur server streaming musik Ampache di Ubuntu 20.04.

Prasyarat

  • Server yang menjalankan Ubuntu 20.04.
  • Kata sandi root telah disiapkan di server Anda.

Memulai

Sebelum memulai, sebaiknya perbarui paket sistem Anda ke versi terbaru. Anda dapat memperbaruinya menggunakan perintah berikut:

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

Setelah semua paket diperbarui, mulai ulang sistem Anda untuk menerapkan perubahan.

Instal Server LAMP

Ampache berjalan di server web, ditulis dalam PHP dan menggunakan MySQL/MariaDB untuk menyimpan datanya. Jadi, Anda perlu menginstal Apache, MariaDB, PHP, dan ekstensi PHP lain yang diperlukan di sistem Anda. Anda dapat menginstalnya dengan menjalankan perintah berikut:

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

Setelah semua paket terinstal, buka file php.ini dan atur beberapa pengaturan:

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

Ubah nilai berikut:

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

Simpan dan tutup file setelah Anda selesai. Kemudian, restart layanan Apache untuk menerapkan perubahan:

systemctl restart apache2

Konfigurasi Database MariaDB

Secara default, MariaDB tidak diamankan. Anda dapat mengamankannya dengan menjalankan skrip berikut:

mysql_secure_installation

Jawab semua pertanyaan seperti yang ditunjukkan di bawah ini:

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

Setelah MariaDB diamankan, masuk ke shell MariaDB dengan perintah berikut:

mysql -u root -p

Berikan kata sandi root MariaDB Anda dan buat database dan pengguna untuk Ampache dengan perintah berikut:

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

Selanjutnya, berikan semua hak istimewa ke database Ampache dengan perintah berikut:

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

Selanjutnya, flush hak istimewa dan keluar dari shell MariaDB menggunakan perintah berikut:

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

Unduh Ampache

Anda dapat mengunduh versi terbaru Ampache menggunakan perintah berikut:

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

Setelah unduhan selesai, unzip file yang diunduh ke direktori root web Apache:

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

Selanjutnya, ubah kepemilikan direktori Ampache menjadi www-data:

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

Selanjutnya, ubah direktori menjadi amache dan ganti nama file .htaccess yang diperlukan.

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

Selanjutnya, buat direktori untuk menyimpan file musik dan ubah kepemilikannya menjadi www-data:

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

Setelah selesai, Anda dapat melanjutkan ke langkah berikutnya.

Konfigurasi Apache untuk Ampache

Selanjutnya, Anda perlu membuat file konfigurasi virtual host Apache baru untuk Ampache. Anda dapat membuatnya dengan perintah berikut:

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

Tambahkan baris berikut:

<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>

Simpan dan tutup file setelah Anda selesai. Kemudian, periksa file konfigurasi Apache untuk kesalahan dengan perintah berikut:

apachectl configtest

Anda akan mendapatkan output berikut:

Syntax OK

Selanjutnya, aktifkan file konfigurasi virtual host Apache dan modul yang diperlukan dengan perintah berikut:

a2ensite ampache
a2enmod expires rewrite

Terakhir, restart layanan Apache untuk menerapkan perubahan:

systemctl reload apache2

Pada titik ini, Ampache diinstal dan dikonfigurasi. Sekarang Anda dapat melanjutkan ke langkah berikutnya.

Amankan Ampache dengan Let's Encrypt SSL

Direkomendasikan untuk mengamankan situs Ampache Anda dengan Let's Encrypt SSL.

Pertama, instal klien Certbot untuk mengunduh dan menginstal Let's Encrypt SSL untuk situs web Anda.

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

Setelah terinstal, jalankan perintah berikut untuk menginstal Let's Encrypt SSL untuk situs web Anda.

certbot --apache -d ampache.linuxbuz.com

Anda akan diminta untuk memberikan alamat email Anda dan menerima persyaratan layanan seperti yang ditunjukkan di bawah ini:

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

Selanjutnya, Anda harus memilih apakah akan mengarahkan ulang lalu lintas HTTP ke HTTPS seperti yang ditunjukkan di bawah ini:

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

Ketik 2 dan tekan Enter untuk melanjutkan. Setelah instalasi selesai, Anda akan mendapatkan output berikut:

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

Selanjutnya, uji pembaruan otomatis sertifikat Let's Encrypt dengan perintah berikut:

certbot renew --dry-run

Jika tes berhasil, Anda akan mendapatkan output berikut:

** 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.)

Akses Antarmuka Web Ampache

Situs web Ampache Anda sekarang diamankan dengan Let's Encrypt SSL. Selanjutnya, buka browser web Anda dan ketik URL https://ampache.linuxbuz.com. Anda akan diarahkan ke halaman berikut:

Pilih bahasa Anda dan klik Mulai Konfigurasi tombol. Anda akan melihat halaman berikut:

Pastikan semua ekstensi PHP yang diperlukan sudah terpasang lalu klik tombol Lanjutkan tombol. Anda akan melihat halaman berikut:

Berikan detail database Anda, hapus centang Buat Database, centang Buat Tabel, hapus centang Buat Pengguna Database dan klik Sisipkan Basis Data tombol. Anda akan melihat halaman berikut:

Berikan detail basis data Anda, pilih ffmpeg dan klik Buat Konfigurasi . Anda akan melihat halaman berikut:

Berikan nama pengguna, kata sandi admin Anda, dan klik tombol Buat Akun tombol. Anda akan melihat halaman berikut:

Klik Perbarui Sekarang tombol untuk memperbarui semua paket yang diperlukan. Anda akan melihat halaman berikut:

Klik Kembali ke halaman utama tautan. Anda akan melihat halaman berikut:

Berikan nama pengguna, kata sandi admin Anda, dan klik Masuk tombol. Anda akan melihat dasbor Ampache di halaman berikut:

Kesimpulan

Selamat! Anda telah berhasil menginstal dan mengamankan Ampache di server Ubuntu 20.04. Sekarang Anda dapat membuat katalog baru, mengunggah musik, dan memutarnya melalui internet.


Ubuntu
  1. Cara Menginstal Server Streaming Musik Koel di Ubuntu 18.04

  2. Cara Instal OpenLiteSpeed ​​Web Server PHP dan MariaDB di Ubuntu 20.10

  3. Cara Menginstal MariaDB di Ubuntu 22.04

  1. Cara Menginstal MariaDB di Ubuntu 18.04

  2. Cara Menginstal MariaDB di Ubuntu 20.04

  3. Cara menginstal Server Streaming Musik Sonerezh di Ubuntu 18.04 LTS

  1. Cara Menginstal Server Streaming Media Icecast 2 di Ubuntu 18.04 LTS

  2. Cara Menginstal Server PowerDNS dan Admin PowerDNS di Ubuntu 20.04

  3. Cara Memasang Server Streaming Musik Ampache di Fedora 33