Поиск по сайту:

Как установить Koel Music Streaming Server на Ubuntu 18.04


Koel — это персональное веб-приложение для потоковой передачи аудио, написанное на Vue.js на стороне клиента и Laravel на стороне сервера. В этом руководстве рассказывается, как установить Koel на сервер на базе Ubuntu 18.04.

Предпосылки

  • A server running Ubuntu 18.04.

  • A non-root sudo user.

  • Make sure everything is updated.

    $ sudo apt update && sudo apt upgrade
  • Few packages that your system needs.

    $ sudo apt install ca-certificates curl unzip build-essential libpng-dev gnupg2 lsb-release ufw -y

    Some of these packages may already be installed on your system.

Настроить брандмауэр

$ sudo ufw allow OpenSSH
$ sudo ufw enable
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw status
Status: active
To                         Action     From
--                         ------      ----
OpenSSH                   ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443/tcp                   ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80/tcp (v6)               ALLOW       Anywhere (v6)
443/tcp (v6)               ALLOW       Anywhere (v6)

Установить Гит

$ sudo apt install git -y
$ git config --global user.name "Your Name"
$ git config --global user.email ""

Установите Node.js

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs
$ node --version
v10.17.0

Установить пряжу

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt update && sudo apt install -y yarn
$ yarn --version
1.19.1

Установить PHP

$ sudo apt install -y php7.2-fpm php7.2-mbstring php7.2-bcmath php7.2-xml php7.2-mysql php7.2-curl php7.2-zip
$ php --version
PHP 7.2.24-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:29:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
  with Zend OPcache v7.2.24-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Установить MariaDB

$ sudo apt install mariadb-server
$ mysql --version
mysql  Ver 15.1 Distrib 10.1.41-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
$ sudo mysql_secure_installation
$ sudo mysql -u root
use mysql;
update user set plugin='' where User='root';
flush privileges;
exit
$ sudo systemctl restart mariadb.service
$ sudo mysql -u root -p

Настройте MariaDB для Koel

$ sudo mysql -u root
mysql> CREATE DATABASE koelmusic;
mysql> CREATE USER 'koeluser'@'localhost' IDENTIFIED BY 'yourpassword';
mysql> GRANT ALL PRIVILEGES ON koelmusic.* TO 'koeluser'@'localhost';
mysql> FLUSH PRIVILEGES;
mysql> exit

Установите Nginx

$ sudo apt install nginx
$ nginx -v
nginx version: nginx/1.14.0 (Ubuntu)
$ sudo nano /etc/nginx/sites-available/koel.conf
server {
 listen         *:80;
 server_name     koel.example.com;
 root           /var/www/koel;
 index           index.php;

 gzip           on;
 gzip_types     text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
 gzip_comp_level 9;

 # Whitelist only index.php, robots.txt, and some special routes
 if ($request_uri !~ ^/$|index\.php|robots\.txt|(public|api)/|remote|api-docs|sw\.js) {
   return 404;
}

 location /media/ {
   internal;

   alias       $upstream_http_x_media_root;

   access_log /var/log/nginx/koel.access.log;
   error_log /var/log/nginx/koel.error.log;
}

 location / {
   try_files   $uri $uri/ /index.php?$args;
}

 location ~ \.php$ {
   try_files $uri $uri/ /index.php?$args;
   fastcgi_param PATH_INFO $fastcgi_path_info;
   fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
   fastcgi_index index.php;
   fastcgi_split_path_info   ^(.+\.php)(/.+)$;
   fastcgi_intercept_errors on;
   include fastcgi_params;
}
}
$ sudo ln -s /etc/nginx/sites-available/koel.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx

Установить Композитор

$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php composer-setup.php
$ php -r "unlink('composer-setup.php');"
$ sudo mv composer.phar /usr/local/bin/composer
$ composer --version
Composer version 1.9.1 2019-11-01 17:20:17

Установить Коэль

$ sudo mkdir -p /var/www/koel
$ cd /var/www/koel
$ sudo chown -R user:user /var/www/koel
$ git clone --recurse-submodules https://github.com/phanan/koel.git .
$ git checkout v4.1.1
$ composer install
$ php artisan koel:init
$ sudo chown -R www-data:www-data /var/www/koel

Настроить Коэль

$ sudo nano /var/www/koel/.env
$ php artisan koel:admin:change-password
$ php artisan koel:sync
Koel syncing started.
953/953 [????????????????????????????] 100%
Completed! 944 new or updated song(s), 0 unchanged song(s), and 9 invalid file(s).
$ crontab -e
0 0 * * * cd /var/www/koel && /usr/bin/php artisan koel:sync >/dev/null 2>&1

Настройка HTTPS с помощью Lets Encrypt

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt install python-certbot-nginx
$ sudo certbot --nginx -d koel.example.com
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):

Заключение