Koel (also styled as koel, with a lowercase k) is a web-based personal audio streaming service written in Vue at the client side and Laravel on the server side. Targeting web developers, Koel embraces some of the more modern web technologies – flexbox, audio and drag-and-drop API to name a few – to do its job.
Koel has two components, each with its own set of requirements:
- All requirements by Laravel – PHP, OpenSSL, composer and such. Consider setting PHP's
memory_limitto a good value (512M or better) if you have a big library.
- MySQL, MariaDB, PostgresSQL, or SQLite. Actually, any DBMS supported by Laravel should work.
- NodeJS latest stable with
- Any decent web browser will do – Koel has been tested on Chrome 47, Firefox 42, Safari 8, Opera 34, and Edge.
From your console, run the following commands:
cd <PUBLIC_WEB_DIRECTORY_FOR_KOEL> git clone --recurse-submodules https://github.com/phanan/koel.git . git checkout v4.0.0 # Check out the latest version at https://github.com/phanan/koel/releases composer install php artisan koel:init # Populate credentials during the process php artisan serve
You should now be able to visit http://localhost:8000 in your browser and start using Koel.
Use a proper webserver
http://localhost:8000 is only the development server for Koel (or rather, Laravel). For optimal performance, you'll want to set up the production version, the configuration of which varies depending on your webserver of choice (Apache, nginx, Caddy etc.) and is outside of this document's scope, but shouldn't be any different from that of a standard PHP application.
If you're on Debian, here's an unofficial installation guide. This may or may not be out of date, so use it with your own risk.
If you want more control, edit
.env file. There's quite a few settings there to tweak Koel to your needs. Remember to reload the server for the changes to take effects.
Check out Releases for upgrade guides corresponding to your Koel version.
# Configuration and Usage
# Music Discovery
There are several ways for Koel to discover your media files. You can manually scan for songs, configure a watcher, host your files with Amazon S3, or upload files directly using the web interface.
# Scan for Songs
The default music discovery method. Upload your songs into a readable directory on your server – preferably outside of your web root dir – and configure Koel to scan and sync it by setting a "media path" under Manage ▸ Settings.
You can also scan from the CLI – which is faster, without a time limit, and provides feedbacks – with the artisan
$ php artisan koel:sync Koel syncing started. 953/953 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100% Completed! 944 new or updated song(s), 0 unchanged song(s), and 9 invalid file(s).
Suffix the command with a
-v flag for more details e.g. syncing errors.
This command can also be added as a cron job, for example to run every midnight:
0 0 * * * cd /home/user/webapps/koel/ && /usr/local/bin/php artisan koel:sync >/dev/null 2>&1
As of current, Koel recognizes these audio extensions:
.m4a (experimental), and
.flac (experimental with some limitations). Others may be added in the future.
If you're syncing compilation albums (albums with multiple songs from different artists) make sure the "Band" tag is set, otherwise each song will end up in its own album. Some ripping software set this automatically; check if yours does.
# Watch a directory
Starting from v2.1.0, you can watch a directory and sync on the fly with
# Host your media on Amazon S3
Starting from v3.0.0, you can use Koel with Amazon S3.
# Upload using the web interface
Starting from v4.3.0, if you're logged in as an admin, you can upload songs directly by clicking the "Upload" sidebar menu item. Note that you need to set the media path first, as songs will be uploaded into a
Depending on how big your media files are, you may want to set
post_max_size in your
php.ini correspondingly, or PHP may fail with a
Payload too large error.
# Streaming Music
Koel supports three streaming methods which can be configured via a
STREAMING_METHOD setting in
php: Use native PHP
readfile(). This is the default method, and the slowest and most unstable one. Only use this method if you can't others.
x-sendfile: Use Apache's mod_xsendfile module. You'll need to install and configure the module manually. A sample configuration is as following:
LoadModule xsendfile_module libexec/apache2/mod_xsendfile.so # These configuration can be put in the VirtualHost directive as well <IfModule mod_xsendfile.c> XSendFile on XSendFilePath /mnt/media </IfModule>
STREAMING_METHOD doesn't have effects if you're serving songs from Amazon S3.
# Using the Web Interface
Using the client component of Koel should be straightforward enough. If you've ever used Spotify, you should feel right at home. As a matter of fact, Koel's client interface is a shameless rip-off of Spotify's. You can search, you can sort, you can view by artists or albums, you can create playlists, you can like/unlike songs, and you can create other users to share the vibes. There are a couple of shortcut keys, too, for the nerds:
- F sets the focus into global search box
- Enter plays a song. If multiple songs are being selected, Enter adds them to the bottom of the queue, Shift+Enter queues them to top. Adding a Cmd or Ctrl into the combo plays the first selected song right away.
- Space toggles playback
- J plays the next song in queue
- K plays the previous song in queue
- Ctrl/Cmd+A selects all songs in the current view
- Delete removes selected song(s) from the current queue/playlist
On a modern Chromium-based browser, you can control Koel using hardware media keys without even having Koel or the browser focused.
# Remote Controller
Starting from v3.7.0, Koel has a (mobile) remote controller that lets you control a desktop instance – play/pause, navigate, turn volume up/down, and add/remove from Favorites.
In order to use the feature:
- Register a Pusher account and create an app
- Populate the app's credentials into
.env(those start with
- Reload the desktop Koel instance
- Go to http://<your-koel-host>/remote on a mobile device to start controlling remotely. You may also want to add the URL to the home screen for faster access later.
# Reset Admin Password
Starting from v4.1.1, Koel comes with a handy CLI command to reset the admin password in case you lose it:
php artisan koel:admin:change-password
For older versions, you can make use of Laravel's Tinker, as described here.
# Mobile Support and Limitation
Koel's fully responsive GUI works fairly well on a mobile device. Certain functionalities are not available (yet), however:
- Shortcut keys don't work (duh)
- Equalizer may not work
- Volume must be controlled from a system level
- Next and previous songs can't be controlled from Control Center or lock screen
Also, since Safari is the new IE, if you're on iOS, it's strongly advised to use Koel with a non-Safari browser such as Firefox, Microsoft Edge, Brave, or Google Chrome. iOS 14 comes with the ability to change the default browser as well.
I decided to write Koel out of my desperation of not being able to find a decent and simple streaming service that fits my needs. This is my very first hands-on with Vue and ES6, and the code must smell so bad. So, any contribution is much appreciated. Bug reports? Bug fixes? Code optimization? Tests? Ideas? Documentation? Please send them over.
# Sponsors and Support
The continuous development of Koel is made possible thanks to the support of these awesome sponsors: