How to install Sonerezh on Ubuntu 14.04

install-sonerezh-on-an-ubuntu-14-04-vpsIn this guide, we will explain how to install Sonerezh on an Ubuntu 14.04 VPS with MariaDB, PHP-FPM and Nginx. Sonerezh is an open source self-hosted application for streaming music. Sonerezh is build with PHP on top of the CakePHP framework and with the latest web technologies. This guide should work on other Linux VPS systems as well but was tested and written for an Ubuntu 14.04 VPS.

Login to your VPS via SSH

ssh user@vps

Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade

In order to convert the tracks we will need the avconv command which is included in the libav-tools package

[user]$ sudo apt-get install software-properties-common libav-tools nano git

Install MariaDB 10.1

To add the MariaDB repository to your sources list and install the latest MariaDB server, run the following commands:

[user]$ sudo apt-key adv --recv-keys --keyserver hkp:// 0xcbcb082a1bb943db
[user]$ sudo add-apt-repository 'deb trusty main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mariadb-server

When the installation is complete, run the following command to secure your installation:

[user]$ mysql_secure_installation

Next, we need to create a database for our Sonerezh installation.

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE sonerezh;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON sonerezh.* TO 'sonerezh'@'localhost' IDENTIFIED BY 'sonerezh_passwd';
MariaDB [(none)]> \q

Install PHP, composer and required PHP modules

To install the latest stable version of PHP version 5.6 and all necessary modules, run:

[user]$ sudo add-apt-repository -y ppa:ondrej/php5-5.6
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install php5-fpm php5-cli php5-gd php5-mysqlnd php5-mcrypt php5-curl php5-intl

PHP-FPM configuration

Create a new PHP-FPM pool for your user:

[user]$ sudo nano /etc/php5/fpm/pool.d/your_username.conf
user = your_username
group = your_username
listen = /var/run/php5-fpm-your_username.sock
listen.owner = your_username = your_username
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Do not forget to change your_username with your username.

Restart PHP-FPM:

[user]$ sudo service php5-fpm restart

Clone Sonerezh

Create a root directory for your Sonerezh installation using the following command:

[user]$ mkdir -p ~/{public_html,logs}

Clone the github repository

git clone --branch master ~/

Create a root directory for your music data

mkdir -p /home/your_username/

Install and configure Nginx

Ubuntu 14.04 comes with nginx version 1.4, to install the latest stable version of Nginx version 1.8, run:

[user]$ sudo add-apt-repository -y ppa:nginx/stable
[user]$ sudo apt-get update
[user]$ sudo apt-get -y install nginx

Create a new Nginx server block with the following content:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

[user]$ sudo nano /etc/nginx/sites-available/
server {
    listen      80;
    root        /home/your_username/;

    access_log /home/your_username/;
    error_log /home/your_username/;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
        expires 14d;
        add_header Cache-Control 'public';

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm-your_username.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

Do not forget to change your_username with your username.

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

Final steps

Open in your favorite web browser and you should see the Sonerezh install screen. Provide the database information, enter the path to your music data and follow the installation wizard instructions.

That’s it. You have successfully installed Sonerezh on your Ubuntu 14.04 VPS. For more information about how to manage your Sonerezh installation, please refer to the official Sonerezh documentation.

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Comment