How to install Koel on Arch Linux

koel.dev/">Koel is an open-source personal music streaming server that allows you to stream your music collection from anywhere with internet access. In this tutorial, we will go through the steps to install Koel on Arch Linux.

Prerequisites

Before we begin, make sure that you have the following installed on your system:

Step 1: Install dependencies

Install the required packages using the following command:

sudo pacman -S git curl unzip wget php php-fpm php-gd php-intl php-mbstring php-pdo_mysql php-xml ffmpeg

Step 2: Install Composer

Composer is a dependency manager for PHP. You can install it by running the following command:

curl -sS https://getcomposer.org/installer | php

Next, move the composer.phar file to the /usr/local/bin directory using the following command:

sudo mv composer.phar /usr/local/bin/composer

Step 3: Download and Install Koel

Clone the Koel repository from GitHub using the following command:

git clone https://github.com/koel/koel.git

Move the cloned directory to your web server's document root directory:

sudo mv koel /usr/share/webapps/

Switch to the koel directory:

cd /usr/share/webapps/koel

Install Koel's dependencies:

composer install --no-dev --prefer-dist --optimize-autoloader --no-progress --no-suggest

Copy the sample environment configuration file:

cp .env.example .env

Generate a new application key:

php artisan key:generate

Step 4: Configure Koel

Edit the .env file using your preferred text editor:

sudo nano .env

Set the database details based on your MySQL/MariaDB configuration:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=koel
DB_USERNAME=your_mysql_username
DB_PASSWORD=your_mysql_password

Step 5: Set up the web server

Apache configuration

Create a new Apache virtual host configuration file named koel.conf:

sudo nano /etc/httpd/conf/extra/koel.conf

Then, add the following configuration:

<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot "/usr/share/webapps/koel/public"
    <Directory "/usr/share/webapps/koel/public">
        AllowOverride All
        Options FollowSymlinks
        Require all granted
    </Directory>
</VirtualHost>

Finally, enable the httpd service and restart Apache:

sudo systemctl enable httpd
sudo systemctl restart httpd

Nginx configuration

Create a new Nginx server block configuration file named koel.conf:

sudo nano /etc/nginx/conf.d/koel.conf

Then, add the following configuration:

server {
    listen 80;
    server_name your-domain.com;
    root /usr/share/webapps/koel/public;
    index index.php;

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

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param REQUEST_URI $request_uri;
        fastcgi_param DOCUMENT_URI $document_uri;
        fastcgi_param DOCUMENT_ROOT $document_root;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param SERVER_SOFTWARE "$server_name $server_version";
        fastcgi_param REMOTE_ADDR $remote_addr;
        fastcgi_param REMOTE_PORT $remote_port;
        fastcgi_param SERVER_ADDR $server_addr;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param REDIRECT_STATUS 200;
        gzip_static on;
    }
}

Finally, enable the nginx service and restart Nginx:

sudo systemctl enable nginx
sudo systemctl restart nginx

Step 6: Set up the database

Log in to MySQL/MariaDB and create a new database for Koel:

mysql -u root -p
CREATE DATABASE koel;

Create a new database user and grant permissions:

CREATE USER 'your_mysql_username'@'localhost' IDENTIFIED BY 'your_mysql_password';
GRANT ALL ON koel.* TO 'your_mysql_username'@'localhost';
FLUSH PRIVILEGES;

Step 7: Run the migration

Migrate the database schema and seed the initial data:

php artisan migrate --seed

Step 8: Access Koel

You can now access Koel by visiting http://<your domain> in your web browser. You will be asked to log in using the default administrator account:

Username: root@koel.dev
Password: admin

Conclusion

Congratulations! You have successfully installed Koel on your Arch Linux system. You can now add your music library 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!