Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing koel on a raspberry pi 3 with nginx and ffmpeg

This is how I installed https://github.com/phanan/koel on a raspberry pi.

Still, flac transcoding isn't working for me

install dependencies

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mariadb-server mysql-client nginx php5-fpm php5-cli php5-mcrypt php5-mysql php5-curl git

nodejs

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs    

yarn

sudo curl -o- -L https://yarnpkg.com/install.sh | bash        

create database

mysql -u root -p
> CREATE DATABASE koel DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
> exit;

#koel

cd /var/www
sudo git clone https://github.com/phanan/koel.git     
sudo chmod 777 -R koel
cd koel/

set your config parameters in .env file.

sed -i 's/ADMIN_EMAIL=/ADMIN_EMAIL=admin@example.com/g' .env
sed -i 's/ADMIN_NAME=/ADMIN_NAME=admin/g' .env
sed -i 's/ADMIN_PASSWORD=/ADMIN_PASSWORD=admin-pass/g' .env
sed -i 's/DB_CONNECTION=/DB_CONNECTION=mysql/g' .env
sed -i 's/DB_HOST=/DB_HOST=localhost/g' .env
sed -i 's/DB_DATABASE=homestead/DB_DATABASE=koel/g' .env
sed -i 's/DB_USERNAME=homestead/DB_USERNAME=root/g' .env 
sed -i 's/STREAMING_METHOD=/STREAMING_METHOD=x-accel-redirect/g' .env

install components

cd /var/www/koel
npm install
sudo npm install gulp
yarn
./node_modules/.bin/gulp --production
php artisan koel:init
sudo chown -R :www-data /var/www/koel 

create your music folder & fill it

sudo mkdir /var/music
sudo chmod 775 /var/music

configure php-fpm & nginx

sudo vim /etc/php5/fpm/php.ini

set cgi.fix_pathinfo=0

sudo php5enmod mcrypt
sudo service php5-fpm restart
sudo vim /etc/nginx/sites-available/default

I have this content :

  server {
    listen          *:80;
    server_name      yourdomain.tld raspberrypi.local;
    root            /var/www/koel;
    index           index.php;

    gzip            on;
    gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json;
    gzip_comp_level  9;

   # Whitelist only index.php, robots.txt, and those start with public/ or api/
   if ($request_uri !~ ^/$|index\.php|robots\.txt|api/|public/) {
     return 404;
   }

  location /media/ {
    internal;

    # A 'X-Media-Root' should be set to media_path settings from upstream
    alias       $upstream_http_x_media_root;

    access_log /var/log/nginx/koel.access.log;
    error_log  /var/log/nginx/koel.error.log;
  }

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

    location ~ \.php$ {
        #try_files $uri /index.php =404;
        try_files $uri $uri/ /index.php?$args;

        #fastcgi_param     PATH_INFO $fastcgi_path_info;
        #fastcgi_param     PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param     SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_intercept_errors  on;

        include fastcgi_params;
    }
}

Then restart nginx to apply changes

sudo service nginx restart

add local swap file (optional)

sudo fallocate -l 1G /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile          

compile ffmpeg (for transcoding)

cd
git clone --depth=1 git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg/
./configure --arch=armel --target-os=linux --enable-gpl --enable-nonfree --enable-demuxer=flac --enable-muxer=flac --enable-decoder=flac --enable-encoder=flac --enable-parser=flac
make -j4
sudo make install

sources

The unofficial install tutorial for debian

@gerroon

This comment has been minimized.

Copy link

@gerroon gerroon commented Oct 10, 2017

your script is missing npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.