Koel is a web-based personal music streaming server that allows users to stream their music collections from any device with internet connectivity. In this tutorial, we will walk you through the steps to install Koel on Alpine Linux Latest.
Before you start, ensure that you have the following:
First, update your system by running the following command:
sudo apk update
Then, install necessary dependencies:
sudo apk add git curl nodejs npm php php-fpm php-mbstring php-xml php-pdo php-json php-session php-gd imagemagick
Next, clone the Koel repository from Github:
git clone https://github.com/koel/koel.git
Composer is a dependency manager for PHP. We need to install it first to install Koel dependencies:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
Navigate to the Koel directory and install its dependencies using Composer:
cd koel
composer install --no-dev --prefer-dist
Koel requires a database to store its data. In this step, we will create a MySQL database and a user for Koel.
Install MySQL client and server:
sudo apk add mariadb mariadb-client
Start the MySQL service:
sudo rc-update add mariadb
sudo rc-service mariadb start
Configure the root user:
sudo mysql_secure_installation
Log in to MySQL:
sudo mysql -u root -p
Create a new database, a new user, and grant access to the user:
CREATE DATABASE koel DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
CREATE USER 'koeluser'@'localhost' IDENTIFIED BY 'password'; --Replace password with a secure password
GRANT ALL PRIVILEGES ON koel.* TO 'koeluser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Make a copy of the .env.example
file and rename it to .env
:
cp .env.example .env
Edit the .env
file and add the database configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=koel
DB_USERNAME=koeluser --Replace with the username created in Step 5
DB_PASSWORD=password --Replace with the password created in Step 5
Build the frontend assets:
npm install
npm run dev
Change the following PHP settings in the /etc/php/php.ini
file:
cgi.fix_pathinfo=0
date.timezone=UTC
Start the PHP-FPM and NGINX services:
sudo rc-update add php-fpm7
sudo rc-service php-fpm7 start
sudo apk add nginx
sudo rc-update add nginx
sudo rc-service nginx start
Create an Nginx configuration file named /etc/nginx/conf.d/koel.conf
:
sudo nano /etc/nginx/conf.d/koel.conf
Add the following configuration:
server {
listen 80;
server_name localhost; # Replace with your domain name (if any)
root /path/to/koel/public; # Replace with your Koel installation path
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm7.sock; # Or use 127.0.0.1:9000 if you prefer TCP
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
}
Finally, restart NGINX:
sudo rc-service nginx restart
Access your Koel installation by opening a web browser and navigating to http://localhost
. You should see the Koel login screen. Log in using the default credentials (email: admin@koel.dev
and password: admin
).
You have successfully installed Koel on Alpine Linux Latest. You can now upload your music collection and start streaming your favorite tunes!
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!