GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare il server di streaming musicale Ampache su Ubuntu 20.04

Ampache è un software gratuito, open source e basato sul Web che ti consente di ospitare il tuo server di streaming musicale. Con Ampache, puoi accedere alla tua musica e ai tuoi video su Internet. Puoi visualizzare, modificare e riprodurre la tua musica tramite un browser web o qualsiasi client di streaming multimediale.

Caratteristiche

  • Potente API e streaming su qualsiasi client
  • Catalogo flessibile e personalizzazione
  • Lettore Web HTML5 moderno
  • Supporta vari metodi di autorizzazione come MySQL, LDAP, HTTP e PAM
  • Compatibilità con qualsiasi client Subsonic

In questo tutorial impareremo come configurare il server di streaming musicale Ampache su Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Una password di root è impostata sul tuo server.

Per iniziare

Prima di iniziare, è una buona idea aggiornare il pacchetto del sistema all'ultima versione. Puoi aggiornarli usando il seguente comando:

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

Una volta aggiornati tutti i pacchetti, riavvia il sistema per applicare le modifiche.

Installa il server LAMP

Ampache viene eseguito sul server web, scritto in PHP e utilizza MySQL/MariaDB per memorizzare i suoi dati. Quindi dovrai installare Apache, MariaDB, PHP e altre estensioni PHP richieste nel tuo sistema. Puoi installarli eseguendo il seguente comando:

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

Una volta installati tutti i pacchetti, apri il file php.ini e modifica alcune impostazioni:

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

Modifica i seguenti valori:

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

Salva e chiudi il file quando hai finito. Quindi, riavvia il servizio Apache per implementare le modifiche:

systemctl restart apache2

Configura il database MariaDB

Per impostazione predefinita, MariaDB non è protetta. Puoi proteggerlo eseguendo il seguente script:

mysql_secure_installation

Rispondi a tutte le domande come mostrato di seguito:

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

Una volta che MariaDB è protetto, accedi alla shell di MariaDB con il seguente comando:

mysql -u root -p

Fornisci la tua password di root MariaDB e crea un database e un utente per Ampache con il seguente comando:

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

Quindi, concedi tutti i privilegi al database Ampache con il seguente comando:

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

Quindi, svuota i privilegi ed esci dalla shell MariaDB usando il seguente comando:

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

Scarica Ampache

Puoi scaricare l'ultima versione di Ampache usando il seguente comando:

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

Una volta completato il download, decomprimere il file scaricato nella directory principale Web di Apache:

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

Quindi, cambia la proprietà della directory Ampache in www-data:

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

Quindi, cambia la directory in ampache e rinomina il file .htaccess richiesto.

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

Quindi, crea una directory in cui archiviare i file musicali e cambia la proprietà in www-data:

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

Una volta terminato, puoi procedere al passaggio successivo.

Configura Apache per Ampache

Successivamente, dovrai creare un nuovo file di configurazione dell'host virtuale Apache per Ampache. Puoi crearlo con il seguente comando:

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

Aggiungi le seguenti righe:

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

Salva e chiudi il file quando hai finito. Quindi, controlla il file di configurazione di Apache per eventuali errori con il seguente comando:

apachectl configtest

Dovresti ottenere il seguente output:

Syntax OK

Quindi, abilita il file di configurazione dell'host virtuale Apache e i moduli richiesti con il seguente comando:

a2ensite ampache
a2enmod expires rewrite

Infine, riavvia il servizio Apache per applicare le modifiche:

systemctl reload apache2

A questo punto Ampache è installato e configurato. Ora puoi procedere al passaggio successivo.

Sicurezza Ampache con Let's Encrypt SSL

Si consiglia di proteggere il tuo sito Web Ampache con Let's Encrypt SSL.

Innanzitutto, installa il client Certbot per scaricare e installare Let's Encrypt SSL per il tuo sito web.

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

Una volta installato, esegui il comando seguente per installare Let's Encrypt SSL per il tuo sito web.

certbot --apache -d ampache.linuxbuz.com

Ti verrà chiesto di fornire il tuo indirizzo e-mail e di accettare i termini del servizio come mostrato di seguito:

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

Successivamente, dovrai scegliere se reindirizzare o meno il traffico HTTP su HTTPS come mostrato di seguito:

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

Digita 2 e premi Invio per continuare. Una volta completata l'installazione, dovresti ottenere il seguente output:

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

Quindi, verifica il rinnovo automatico del certificato Let's Encrypt con il seguente comando:

certbot renew --dry-run

Se il test ha avuto esito positivo, dovresti ottenere il seguente output:

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

Accedi all'interfaccia Web di Ampache

Il tuo sito Web Ampache è ora protetto con Let's Encrypt SSL. Quindi, apri il tuo browser web e digita l'URL https://ampache.linuxbuz.com. Verrai reindirizzato alla seguente pagina:

Seleziona la tua lingua e fai clic su Start Configurazione pulsante. Dovresti vedere la seguente pagina:

Assicurati che tutte le estensioni PHP richieste siano installate, quindi fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Fornisci i dettagli del tuo database, deseleziona Crea database, seleziona Crea tabelle, deseleziona Crea utenti database e fai clic su Inserisci Banca dati pulsante. Dovresti vedere la seguente pagina:

Fornisci i dettagli del tuo database, seleziona ffmpeg e fai clic su Crea Configura . Dovresti vedere la seguente pagina:

Fornisci il nome utente e la password dell'amministratore e fai clic su Crea Account pulsante. Dovresti vedere la seguente pagina:

Fai clic su Aggiorna Ora pulsante per aggiornare tutti i pacchetti richiesti. Dovresti vedere la seguente pagina:

Fai clic su Torna alla pagina principale collegamento. Dovresti vedere la seguente pagina:

Fornisci il nome utente e la password dell'amministratore e fai clic su Accedi pulsante. Dovresti vedere la dashboard di Ampache nella pagina seguente:

Conclusione

Congratulazioni! hai installato e protetto con successo Ampache sul server Ubuntu 20.04. Ora puoi creare il tuo nuovo catalogo, caricare la tua musica e riprodurla su Internet.


Ubuntu
  1. Come installare MariaDB su Ubuntu 18.04

  2. Come installare MariaDB su Ubuntu 20.04

  3. Come installare Koel Music Streaming Server su Ubuntu 18.04

  4. Come installare il server Web OpenLiteSpeed ​​PHP e MariaDB su Ubuntu 20.10

  5. Come installare MariaDB su Ubuntu 22.04

Come installare il server OpenSSH su Ubuntu 20.04 LTS

Come installare l'ultimo lettore musicale Lollypop in Ubuntu 20.04

Come installare MariaDB su Ubuntu 16.04

Come installare Ampache su Ubuntu 20.04 LTS

Come installare il server EteSync su Ubuntu 20.04 LTS

Come installare Plex Media Streaming Server su Ubuntu 19.04