Tuesday, September 22, 2020

Garmin SubMusic (on Ubuntu 18.04)

  1. Install dependencies
  2. Install Nextcloud
  3. Install Music
  4. Install Ampache
  5. Install Garmin SubMusic

Nextcloud

Reference guide

Nextcloud 19 dependencies:
  • PHP >=7.2
  • MySQL/MariaDB
  • Nginx
Ampache dependencies:
  • PHP >=7.2
  • MySQL/MariaDB
  • Nginx
  • Composer

Install PHP

$ sudo apt install -y php-cli php-fpm php-json php-intl php-imagick php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-gmp
php --version

Edit /etc/php/7.2/fpm/php.ini:

    memory_limit = 512M

Edit /etc/php/7.2/fpm/pool.d/www.conf:

    clear_env = no

Restart php:

    $ sudo service php7.2-fpm restart 

Install database server 

$ sudo apt -y install mariadb-server
Secure database server:
$ sudo mysql_secure_installation
Edit /etc/mysql/mariadb.cnf:
[client]
default-character-set = utf8mb4

[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
transaction_isolation = READ-COMMITTED
binlog_format = ROW
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=1

Reload database services:
$ sudo service mysql restart
$ sudo service mariadb restart
Change authentication plugin to allow use of root password:
$ sudo mysql -u root
> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
FLUSH PRIVILEGES;
QUIT;
Create a database and user for Nextcloud Ampache: 
$ mysql -uroot -p 
> CREATE USER 'nextcloud'@'localhost' identified by 'PASSWORD';
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; 
> CREATE USER 'ampache'@'localhost' identified by 'PASSWORD';
CREATE DATABASE ampache;
GRANT ALL PRIVILEGES ON ampache.* TO 'ampache'@'localhost';
FLUSH PRIVILEGES;
QUIT;
Check user's password and privileges:
$ mysql -u nextcloud -p
$ mysql -u ampache -p
> SHOW DATABASES;
QUIT;

Check db configuration:

$ mysql -u root -p
> show variables like 'innodb_file_format';
show variables like 'innodb_file_per_table';
SELECT @@TX_ISOLATION

[deprecated] Install Nextcloud .zip distribution

Download the latest Nextcloud distribution
$ unzip latest-19.zip
$ sudo mv ./nextcloud /var/www/
$ sudo chown -R www-data:www-data /var/www/nextcloud
Restart nginx:
$ sudo nginx -t
$ sudo systemctl restart nginx

Finish nextcloud setup interactively: 

open https://nextcloud.home in browser (index.php should start), enter database credentials and paths, etc.
In case of an "untrasted domain" error page, edit trusted_domains in /var/www/nextcloud/config/config.php, e.g.:
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'server1.example.com',
2 => '192.168.1.50',
3 => '[fe80::1:50]',
), 

Install web server

nginx-extras package is required for WebDAV support and lua-nginx:
$ sudo apt install nginx-extras

Create /etc/nginx/sites-available/nextcloud.conf:

host config [deprecated]

Create /etc/nginx/sites-available/ampache.conf:

host config

Enable a virtual nginx host: 

$ sudo ln -s /etc/nginx/sites-available/nextcloud.conf /etc/nginx/sites-enabled 

Create required paths for ssl certificates and logs (according to the config from above):
$ sudo mkdir /etc/ssl/nginx
$ mkdir -p /home/user/nextcloud.home/logs

$ sudo ln -s ~/Dvlp/keys/nextcloud.home.crt ~/Dvlp/keys/nextcloud.home.key /etc/ssl/nginx/

Remember to import the CA certificate in all your browsers/devices if using self-signed SSL certificates for the host.

Uncomment the line below in /etc/nginx/nginx.conf:
server_names_hash_bucket_size 64;
Restart nginx:
$ sudo nginx -t
$ sudo systemctl restart nginx

Check nginx:

in browser  open http://localhost and see the nginx's debug message.

Edit /etc/hosts:

127.0.1.1 nextcloud.home www.nextcloud.home

Install Ampache

$ mkdir /var/www/ampache
sudo chown -R www-data:www-data /var/www/ampache
cd /var/www/ampache
sudo -u www-data git clone -b master https://github.com/ampache/ampache.git .
Install Composer (skip this step if you have Composer installed: $which composer): 
$ cd ~ 
<download Composer according to the instructions>
$ sudo mv composer.phar /usr/local/bin/composer
 Install ampache's internal dependencies:
$ cd /var/www/ampache
$ sudo -u www-data composer install --prefer-source --no-interaction 

Open the hostname in a browser and finish Ampache installation.

Remember to do configuration steps: https://github.com/ampache/ampache/wiki/Basic.

[deprecated] Nextcloud Music

Install the Music app directly from Nextcloud administrative UI.

Garmin SubMusic

Open ConnectIQ store in Garmin Connect mobile app, find SubMusic app and install it into the smart watches.
See more details here: https://github.com/memen45/SubMusic