Installing Koel on Alpine Linux Latest
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.
Prerequisites
Before you start, ensure that you have the following:
- A machine running Alpine Linux Latest
- Root access or a superuser account with sudo privileges
- A stable internet connection
Step 1: Install required dependencies
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
Step 2: Clone the Koel repository
Next, clone the Koel repository from Github:
git clone https://github.com/koel/koel.git
Step 3: Install Composer
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
Step 4: Install Koel dependencies
Navigate to the Koel directory and install its dependencies using Composer:
cd koel
composer install --no-dev --prefer-dist
Step 5: Configure the database
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;
Step 6: Configure Koel
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
Step 7: Build frontend assets
Build the frontend assets:
npm install
npm run dev
Step 8: Configure PHP
Change the following PHP settings in the /etc/php/php.ini file:
cgi.fix_pathinfo=0
date.timezone=UTC
Step 9: Start Koel
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
Step 10: Configure NGINX
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
Step 11: Accessing Koel
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: [email protected] and password: admin).
Conclusion
You have successfully installed Koel on Alpine Linux Latest. You can now upload your music collection and start streaming your favorite tunes!