Koel is an open source personal music streaming application. Koel is a web-based service and written in Vae on the client side and Laravel on the server side. It provides an easy to use web-based interface to stream the music stored in readable directories of the server. The interface is fully responsive thus can be used flawlessly on any type of modern browser.
In this tutorial, we will be installing Koel on CentOS 7. We will also install all the required dependencies which include Apache, PHP 5.6, Node.js, and MariaDB.
Koel can be installed on systems with at least 1GB of RAM, but the requirement of RAM increases as the number of users increases. You will also need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run
sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Once you have your system updated, run the following command to install few packages on your server.
yum -y install httpd mariadb-server mariadb git
The above command will install the Apache web server with MariaDB database server and Git. Now you will need to install PHP. You can install any version of PHP > 5.5. In this tutorial, we will be installing PHP 5.6. PHP 5.6 is not included in default YUM repository, hence you will need to enable additional webtatic repository. Webtatic repository needs the EPEL repository.
yum -y install epel-release
yum -y update
Now install the Webtatic repository using the following commands.
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update
yum clean all
To install PHP 5.6 and all the required PHP modules, run the following command.
yum -y install php56w php56w-cli php56w-gd php56w-mysql php56w-mcrypt php56w-pear php56w-curl php56w-mbstring
You can check the installed version of PHP using following command.
You should get following output.
[root@lipatn ~]# php -v PHP 5.6.29 (cli) (built: Dec 10 2016 12:42:43) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Once PHP is installed, you will need to configure few thing in
php.ini configuration. Open
/etc/php.ini using your favorite editor.
If you do not have nano installed, you can install it using
yum -y install nano. Scroll down to find the following lines.
; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit memory_limit = 128M
You can increase the
memory_limit to a higher amount so that the processing of PHP can also be done faster.
You will also need to Enable Mod_rewrite by editing
/etc/httpd/conf/httpd.conf using your favorite text editor.
Find the following line under
<Directory "/var/www/html"> block.
Change it to
Now install Composer using the following command. Composer is a dependency manager for PHP.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer
Now install the latest version of Node.js from the nodesource repository. Run the following command for same.
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
yum -y install nodejs
You can also choose to install Yarn, run the following command for to do so.
wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
yum -y install yarn
To start the Apache web server and enable it to start at boot time, run the following command.
systemctl start httpd
systemctl enable httpd
Start MariaDB and enable it to start at boot time using the following commands.
systemctl start mariadb
systemctl enable mariadb
Now run the following command to secure your MariaDB installation.
It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose
y and set a strong password for the installation. It will further ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer
y to all the questions.
Now you will need to create a database with database user to store Koel data. To create a database we will need to login to MySQL command line first. Run the following command for same.
mysql -u root -p
This will prompt you for the root password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your Koel installation.
CREATE DATABASE koel_data;
The above query will create a database named
koel_data. For the database, you can use any name you prefer in the place of
koel_data. Make sure that you use a semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. To create a new database user, run the following query.
CREATE USER 'koel_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username
koel_user. You can use any preferred username instead of
StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command:
GRANT ALL PRIVILEGES ON koel_data.* TO 'koel_user'@'localhost';
Now run the following command to immediately apply the changes on the database privileges.
Exit MySQL prompt by executing
Now install Koel, by cloning the repository on your system.
git clone https://github.com/phanan/koel.git .
Now install Koel using the following command.
The above command will install npm dependencies.
The above command will install all the PHP dependencies.
Now you will need to edit the
.env file, run the following command for the same.
A the start of the file, you will see following lines.
# Database connection name, which corresponds to the database driver. # Possible values are: # mysql (MySQL/MariaDB - default) # pgsql (PostgreSQL) # sqlsrv (Microsoft SQL Server) DB_CONNECTION= DB_HOST= DB_DATABASE= DB_USERNAME= DB_PASSWORD=
DB_CONNECTION= as we are using MariaDB which is a fork of MySQL. Provide
DB_HOST=. Next, provide the database name, username, and database password, which we have created earlier. Finally, it should look like shown below.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=koel_data DB_USERNAME=koel_user DB_PASSWORD=StrongPassword
Next, you will need to provide the initial admin details, once done it should look like this.
ADMIN_EMAILfirstname.lastname@example.org ADMIN_NAME=Liptan ADMIN_PASSWORD=StrongPassword
.env file has been populated, run the following command to initialize the Koel database.
php artisan koel:init
Now you will need to disable your SELinux because MyBB does not work with SELinux policies. To temporary disable SELinux, run the following command.
To completely disable the SELinux you will need to edit /etc/selinux/config file.
If you don't have nano installed, you can install it using yum -y install nano Find the following line:
Change it to:
Now you will need to reboot your server so that the new configuration can take effect. Once the server is rebooted, you will need to provide the ownership of the application to web server user using the following command.
chown -R apache:apache /var/www/html
Now you can go to the following URL to browse the Koel interface using your favorite browser.
You will see the login interface. You can log in using the admin email and password which you have provided in
.env file during installation.
To scan music files stored on the server, run the following command.
php artisan koel:sync
It will scan and add all the music files stored on the server.
In this tutorial, we have learned how to install Koel Music Streaming Server in your CentOS 7 server. You can now listen to the songs on any device having a web browser.