How to install Koel on Void Linux

Koel is a free and open-source personal music streaming server that allows you to easily stream and listen to your music collection from anywhere in the world. In this tutorial, we will explain how to install Koel on Void Linux.

Prerequisites

Before proceeding with this tutorial, you should:

Step 1: Install Required Packages

First, update the package repository cache on your system using the following command:

sudo xbps-install -Suy

Next, install the required packages to run Koel. You can install these packages using the following command:

sudo xbps-install -y nginx php php-fpm php-mbstring php-mysqlnd php-xml mysql-server git

Step 2: Create a Database

Koel requires a database to store its data, and we will use MySQL/MariaDB as our database server. Run the following command to install MySQL/MariaDB if it is not installed on your system:

sudo xbps-install -y mariadb

Once installed, start the MySQL/MariaDB service and enable it to automatically start on boot:

sudo ln -s /etc/sv/mariadb /var/service/

Next, secure the MySQL/MariaDB installation by running the following command:

sudo mysql_secure_installation

Follow the on-screen instructions to secure the installation.

Now, create a new database and user for Koel by running the following commands:

sudo mysql -u root -p

CREATE DATABASE koeldb;
GRANT ALL PRIVILEGES ON koeldb.* TO 'koeluser'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Replace password with a secure password of your choice.

Step 3: Clone the Koel Repository

Now, clone the Koel repository from GitHub by running the following command:

sudo git clone https://github.com/koel/koel.git /var/www/koel

Step 4: Install Composer and Dependencies

If you don't have Composer installed, install it by running the following command:

sudo xbps-install -y composer

Next, navigate to the Koel directory and install the project dependencies using the following commands:

cd /var/www/koel
sudo composer install --no-dev

Step 5: Configure Nginx

Now, open the Nginx configuration file in your preferred text editor:

sudo vi /etc/nginx/nginx.conf

Remove the existing server block and replace it with the following:

server {
    listen 80;
    server_name example.com; # Replace with your domain name or IP address
    root /var/www/koel/public;
    index index.php;

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

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # May be different for your system. Replace it accordingly.
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Save the file and exit.

Restart the Nginx service using the following command:

sudo sv restart nginx

Step 6: Configure Koel

Copy the .env.example file to .env using the following command:

cd /var/www/koel
sudo cp .env.example .env

Now, open the .env file in your preferred text editor:

sudo vi /var/www/koel/.env

Change the following values to match your settings:

APP_ENV=production
APP_DEBUG=false
APP_URL=http://example.com # Replace with your domain name or IP address
DB_HOST=localhost
DB_DATABASE=koeldb
DB_USERNAME=koeluser
DB_PASSWORD=password # Replace with the password you set in Step 2

Save the file and exit.

Step 7: Run the Setup Commands

Run the following commands to set up the Koel application:

cd /var/www/koel
sudo php artisan koel:init
sudo php artisan storage:link

Step 8: Start Using Koel

You can now access the Koel web interface by navigating to http://example.com (replace example.com with your domain name or IP address) in your web browser.

Congratulations! You have successfully installed Koel on Void Linux.

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!