Koel-Set up a music streaming server on Ubuntu / Debian / CentOS

How to set up a personal music streaming server on Ubuntu / Debian / CentOS / Fedora using Koel? Cole Is an open source, simple web-based audio streaming service written in Vue and Laravel PHP Framework. This streaming server is aimed at web developers and it uses modern web technologies such as CSS grids, audio and drag and drop APIe.t.c.

These are the two components of the Koel media streaming service.


  • MySQL, MariaDB, PostgresSQL or SQLite. In fact, any DBMS supported by Laravel will work.
  • PHP, OpenSSL, Composer-for Laravel
  • NodeJS latest stable yarn

Customer requirements

  • Any decent web browser will work-Koel has been tested on Chrome 47, Firefox 42, Safari 8, Opera 34 and Edge.

Our next section will discuss how to install and configure the dependencies required by Koel Music Streaming Server.

Step 1: Install the database server

We will focus on using MariaDB database server. These are reference guides for installation.

MariaDB installation guide:

Install MariaDB database server on Ubuntu

Install MariaDB database server on Debian

Install MariaDB database server on CentOS 8 / CentOS 7

After running the database service, create a database, a user of the service, and grant permissions to that user.

$ mysql -u root -p
CREATE USER 'koel'@'localhost' IDENTIFIED BY '[email protected]';

Step 1: Install PHP and Composer

In this step, we will install PHP, Composer and Nginx httpd server.

Debian / Ubuntu:

sudo apt -y install git curl g++ nginx
sudo apt -y install php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd  php-mbstring php-curl php-xml php-pear php-bcmath

CentOS 7:

sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install git wget curl epel-release yum-utils libpng-devel

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73
sudo yum -y install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json

CentOS 8:

sudo dnf -y install git wget curl yum-utils
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf module reset php
sudo dnf module install php:remi-7.3
sudo yum -y install wget php php-{pear,cgi,common,curl,mbstring,gd,mysqlnd,gettext,bcmath,json,xml,fpm,intl,zip,imap}

Step 3: Install Node.js

Install Nodejs:

--- CentOS ---
sudo curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum -y install nodejs

--- Ubuntu / Debian ---
sudo curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt update
sudo apt -y install nodejs

Installation yarn:

--- CentOS ---
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum -y install yarn

--- Ubuntu / Debian ---
curl -sL 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-get update && sudo apt-get install yarn

Install Composer:

sudo su -
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

Verify the installation by querying the version.

$ composer  --version
Composer version 1.9.3 2020-02-04 12:58:49

Step 4: Install Koel Music Streaming server

Install build dependencies:

--- Ubuntu / Debian
$  sudo apt install -y build-essential libpng-dev gcc make ffmpeg

--- CentOS ---
$ sudo yum -y install epel-release
$ sudo yum group install "Development Tools"
$ sudo yum -y install libpng-devel

To install ffmpeg on CentOS, check:

Install FFmpeg on CentOS Linux

Clone koel project code format is Github.

git clone https://github.com/phanan/koel.git
cd koel
npm install
npm audit fix
composer install

Sample installation output:

nunomaduro/larastan suggests installing orchestra/testbench (^3.6)
php-mock/php-mock suggests installing php-mock/php-mock-phpunit (Allows integration into PHPUnit testcase with the trait PHPMock.)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.6.0)
phpunit/phpunit suggests installing ext-soap (*)
phpunit/phpunit suggests installing ext-xdebug (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^2.0)
Package facebook/webdriver is abandoned, you should avoid using it. Use php-webdriver/webdriver instead.
Generating optimized autoload files
Carbon 1 is deprecated, see how to migrate to Carbon 2.
    You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.
> IlluminateFoundationComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: aws/aws-sdk-php-laravel
Discovered Package: barryvdh/laravel-ide-helper
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: mpociot/laravel-apidoc-generator
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/larastan
Package manifest generated successfully.
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
> @php artisan clear-compiled
Compiled services and packages files removed!
> @php artisan cache:clear
Failed to clear cache. Make sure you have the appropriate permissions.
> @php -r "if (!file_exists('.env')) copy('.env.example', '.env');"

Edit .env Files to make the necessary configuration changes-set database credentials

$ vim .envvim .env
# Database connection name, which corresponds to the database driver.
DB_PASSWORD='[email protected]'

# Credentials and other info to be used when Koel is installed in non-interactive mode
# (php artisan koel:init --no-interaction)
# By default (interactive mode), Koel will still prompt for these information during installation,
# but provide the values here as the defaults (except ADMIN_PASSWORD, for security reason).
ADMIN_NAME="Koel Admin"
ADMIN_EMAIL=[email protected]

# The memory limit, in MB, used by the scanning process.
# For example, if you want to set a memory limit of 2048MB, enter "2048" (without
# quotes) here.

The full path of ffmpeg binary.

Then initialize the database and then start serving the site.

$ php artisan koel:init --no-interaction
$ php artisan serve
Laravel development server started: 

This will only allow connections from localhost. if you are willing to
To accept connections from other hosts, start the server in the following ways
Provide the Host option.

$ php artisan serve --host

Step 5: Configure Nginx

For best performance, you need to set up a production version using Apache or Nginx web server. Install nginx using the following command:

--- Debian / Ubuntu ---
$ sudo apt -y install nginx php-fpm
$ sudo systemctl enable --now nginx

--- CentOS / Debian ---
$ sudo yum -y install nginx
$ sudo systemctl enable --now nginx
$ sudo firewall-cmd --add-service={http,https} --permanent
$ sudo firewall-cmd --reload

Move your koel project folder to the / var / www / html directory.

sudo mv koel /var/www/html

Setting permissions:

--- Debian / Ubuntu ---
$ sudo chown -R www-data:www-data /var/www/html/koel

--- CentOS  ---
$ sudo chown -R apache:apache /var/www/html/koel

Configure Nginx

$ sudo vim /etc/nginx/conf.d/koel.conf

Paste and modify below.

server {
  listen          *:80;
  server_name     koel.example.com;
  root            /var/www/html/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/ {

    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    ;
    fastcgi_pass               unix:/run/php/php7.2-fpm.sock;
    fastcgi_index             index.php;
    fastcgi_split_path_info   ^(.+.php)(/.+)$;
    fastcgi_intercept_errors  on;
    include                   fastcgi_params;

Check the nginx configuration for syntax errors:

$ sudo nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Restart nginx:

sudo systemctl restart nginx

Visit the Koel dashboard at: koel.example.com – The domain is configured.

How to create hard and soft (symbolic) links in Linux

Understanding the Linux file system hierarchy

Install the latest Google Chrome browser on Kali Linux

Setting up Sway Tiling Window Manager on Fedora with Waybar