Sonerezh is a free and open source web-based audio streaming application that can be used to access your music from anywhere. Sonerezh also gives you a user management system with two access levels so that your friends could enjoy your music too.
Sonerezh provides lot’s of features such as Playlist management, supports MySQL and PostgreSQL, simple search engine, extraction of metadata, file import and many more.
In this tutorial, we will explain how to install and configure Sonerezh with Nginx and PHP-FPM on Ubuntu 16.04.
Requirements
- A server runing Ubuntu-16.04 on your system.
- A non-root user with sudo privileges setup on your server.
- A static ip address 192.168.0.23 configured on your server.
Update the System
Before starting, you will need to update the system’s package repository database with the latest version. You can do this with the following commands:
sudo apt-get update -y
sudo apt-get upgrade -y
You your system is up to date you can proceed to the next step.
Installing LEMP Server
Sonerezh is a web-based application that works with your browser. Sonerezh also requires a database to store its data, so you will need a LEMP server installed on your system. If not, you can install it with the following command:
sudo apt-get install nginx mariadb-server php7.0 php7.0-fpm php7.0-mysql php7.0-intl php7.0-cli php7.0-gd php7.0-mbstring php-pear php7.0-curl php7.0-mysqlnd php7.0-mcrypt libav-tools git
Once installation is completed, start the Nginx and MariaDB service and enable them to start at boot with the following command:
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl start mysql
sudo systemctl enable mysql
Once you are done, you can proceed to configure MariaDB database for sonerezh.
Configure MariaDB
By default, MariaDB installation is not secure, so you will need to secure it first by running mysql_secure_installation
script.
You can do this with the following command:
sudo mysql_secure_installation
During the interactive process, answer all the questions as shown below:
Enter current password for root (enter for none): Enter
Set root password? [Y/n]: Y
New password: <your-password>
Re-enter new password: <your-password>
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y
Once MariaDB is secured, you can login to the MySQL shell with the following command:
mysql -u root -p
Enter your root password to log in, then create a database for Sonerezh installation.
MariaDB [(none)]> CREATE DATABASE sonerezhdb;
Query OK, 1 row affected (0.00 sec)
Next, create database user named sonerezh with password password and grant all privileges with the following command:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON sonerezhdb.* TO 'sonerezh'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
Next, flush all privileges:
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Then, exit from the MySQL shell:
MariaDB [(none)]> exit
Once you are done, you can proceed to download and install sonerezh.
Download Sonerezh
You can download the latest version of the Sonerezh from the Git repository with the following command:
First, change the directory to your default web root directory:
cd /var/www/html/
Then, clone the latest version of the sonerezh using git command:
git clone --branch master https://github.com/Sonerezh/sonerezh.git
Next, create a root directory for your music data:
sudo mkdir /var/www/html/sonerezh/Music
Next, give proper permission to the sonerezh directory:
sudo chown -R www-data:www-data /var/www/html/sonerezh
sudo chmod -R 755 /var/www/html/sonerezh
Once you are done, you can proceed to configure Nginx and Php-fpm pool.
Configure Nginx and PHP-FPM
First, you will need to create a new php-fpm pool for www-data user.
sudo nano /etc/php/7.0/fpm/pool.d/www.conf
Add the following lines:
[www-data]
user = www-data
group = www-data
listen = /var/run/php/php7-fpm-www-data.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /
Save and close the file when you are finished, then restart php-fpm service:
sudo /etc/init.d/php7.0-fpm restart
Next, create a new Nginx virtual host block for sonerezh:
sudo nano /etc/nginx/sites-available/sonerezh
Add the following lines:
server {
listen 80;
server_name 192.168.0.23;
root /var/www/html/sonerezh/app/webroot;
access_log /var/log/nginx/sonerezh_access.log;
error_log /var/log/nginx/sonerezh_error.log;
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/php/php7-fpm-www-data.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;
}
}
Note: Where 192.168.0.23 is the IP address of server.
Save and close the file when you are finished, then activate the nginx server block with the following command:
`sudo ln -s /etc/nginx/sites-available/sonerezh /etc/nginx/sites-enabled/
Finally, test nginx for syntax error, then restart the nginx service with the following command:
sudo nginx -t
sudo systemctl restart nginx
Access Sonerezh Web Interface
Once everything is configured properly, it’s time to access sonerezh web installation wizard.
Open your favourite web browser and type the URL http://your-server-ip, you should see the Sonerezh installation screen below:
HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1035094692.png” alt=”” />
Provide the database information, like database name, database username, database password, your email address and enter the path to your music data and follow the installation wizard instructions, you should see the Sonerezh login screen below:
HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/1087081115.png” alt=”” />
Provide a username and password then click on Sign In
button, you should see the Sonerezh default dashboard below:
HP_NO_IMG/data/uploads/users/7ecb43a5-b365-4ebf-93d5-f3b632f29f33/914277603.png” alt=”” />
Conclusion
Congratulatios! You have successfully installed Sonerezh on your Ubuntu 16.04 server. You can now easily listen to your music from anywhere.