Thank you for your donation!


Instruction Guide moOde and Pi-Hole on Nginx
#11
(02-21-2021, 10:20 PM)felichas Wrote: Hi,
Installing pi-hole works fine for me, but breaks Moode Audio.

I was running moode v6.7.1. Followed instructions and ended with a working pi-hole and a broken moode.
I didn't investigate much, to be hones, because I had to update to moode v7.0.1.
I have flashed my RPi Zero with HiFiBerry DAC and upgraded to v7.0.1. moode worked great again.
I have followed this intructions again... and moode is now broken, just like v6.7.1 was.

Configuration pages System, Network and Audio seem to work.
But the configuration page for the Library is now broken
This is the error I get:
Code:
lib-config: Connection to MPD failed

But most importantly, the main player is broken

I see the same error in /var/log/moode.log
Code:
20210221 223036 lib-config: Connection to MPD failed
20210221 223036 moode.php: MPD connect failed: cmd=(playlist)
20210221 223040 moode.php: MPD connect failed: cmd=(playlist)
20210221 223044 moode.php: MPD connect failed: cmd=(lsinfo)
20210221 223044 moode.php: MPD connect failed: cmd=(loadlib)

And no errors in /var/log/php_errors.log


Any advice on how to fix this? I like the idea of having both services in the same device.

I did some more investigation, based on this post.

I think I missed the Integrity check bit from my /var/log/moode.log
Code:
20210222 084056 worker: -- Start
20210222 084057 worker: Successfully daemonized
20210222 084058 worker: Integrity check (failed:1)
20210222 084058 worker: Exited

I guess failed:1 referes to the 1st line of the cfg_hash table

Code:
$ md5sum /etc/nginx/nginx.conf
d0d1e0705a10974f26271f6623d87215  /etc/nginx/nginx.conf

$ sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "SELECT * FROM cfg_hash where id=1"
1|/etc/nginx/nginx.conf|390ed3c2876a41cbe45479a709470410|warning

I have indeed, following the instructions above, modified nginx.conf. And now the md5sum in the database does not match the actual hash of the file. But this should not be a problem, because the record has been now updated to warning   Huh

I can still try to udate the record (1st time I deal with sqlite in my life).

Code:
$ sudo sqlite3 "/var/local/www/db/moode-sqlite3.db"
SQLite version 3.27.2 2019-02-25 16:06:06
Enter ".help" for usage hints.
sqlite> .header on
sqlite> SELECT * FROM cfg_hash where id=1;
id|param|value|action
1|/etc/nginx/nginx.conf|390ed3c2876a41cbe45479a709470410|warning
sqlite> UPDATE cfg_hash SET VALUE = 'd0d1e0705a10974f26271f6623d87215' WHERE ID = 1 ;
sqlite> SELECT * FROM cfg_hash WHERE ID = 1;
id|param|value|action
1|/etc/nginx/nginx.conf|d0d1e0705a10974f26271f6623d87215|warning
sqlite> .quit

And finally, I can confirm everything else is now aligned database and file system

Code:
$ sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "select value,param from cfg_hash" |awk -F'|' '{print $1,$2}' |md5sum --check
/etc/nginx/nginx.conf: OK
/etc/nginx/fastcgi_params: OK
/etc/php/7.3/cli/php.ini: OK
/etc/php/7.3/fpm/php-fpm.conf: OK
/etc/php/7.3/fpm/php.ini: OK
/etc/php/7.3/fpm/pool.d/www.conf: OK
/etc/php/7.3/mods-available/opcache.ini: OK
/tmp/cfg_audiodev.sql: OK
/var/www/command/worker.php: OK
/var/www/inc/playerlib.php: OK
/var/www/css/main.min.css: OK
/var/www/js/config.min.js: OK
/var/www/js/lib.min.js: OK
/var/www/js/main.min.js: OK
/etc/rc.local: OK

But after restarting, I continue getting the same error. Any further help would be much appreciated.
Reply
#12
https://moodeaudio.org/forum/showthread....6#pid30806

Quote:I guess failed:1 referes to the 1st line of the cfg_hash table
1 means the table is not RO, so the last command from database procedure was not apply.

Quote:But this should not be a problem, because the record has been now updated to warning  
Doing that can trigger the verification check (error code: 2), so revert to exit for nginx.conf, and follow only the database procedure.

After that, if that still don't work, check again in moode log the error code for Integrity check line.
Reply
#13
(02-22-2021, 08:45 AM)TookaFace Wrote: https://moodeaudio.org/forum/showthread....6#pid30806

Quote:I guess failed:1 referes to the 1st line of the cfg_hash table
1 means the table is not RO, so the last command from database procedure was not apply.

Quote:But this should not be a problem, because the record has been now updated to warning  
Doing that can trigger the verification check (error code: 2), so revert to exit for nginx.conf, and follow only the database procedure.

After that, if that still don't work, check again in moode log the error code for Integrity check line.

Thanks for the tip. I solved it now.

The database was locked and would not let me do the UPDATE nor the CREATE TRIGGER.
A little googling showed me how to back up the db. Apply the changes in the back up and swap them was easy. 

Regards,
Reply
#14
Hi everyone, I can confirm that this works for MoOde 7.1.0 too! Smile
Reply
#15
(11-30-2019, 04:37 PM)TookaFace Wrote: Just a little how-to for running Pi-Hole with moOde on Nginx web server.

Works for moOde 6.4 and higher

    - Install Pi-Hole:
Code:
curl -sSL https://install.pi-hole.net | bash

     - When prompted, answer Off to that question:
Code:
Do you wish to install the web server (lighttpd) and required PHP modules?
Off

    - Once the installation is complete, open this file:
Code:
sudo nano /etc/nginx/sites-available/default

    - Delete all contents and copy that instead:
Code:
server {
   listen 8080 default_server;
   listen [::]:8080 default_server;

   root /var/www/html;
   server_name _;
   autoindex off;
   error_page 404 /pihole/index.php;

   index pihole/index.php index.php index.html index.htm;

   location / {
       expires max;
       try_files $uri $uri/ =404;
   }

   location ~ \.php$ {
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
       fastcgi_param FQDN true;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location /*.js {
       index pihole/index.js;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location /admin {
       root /var/www/html;
       index index.php index.html index.htm;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location ~ /\.ht {
       deny all;
   }
}

    - Set rights for Pi-Hole folder and add pihole user to www-data group:
Code:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo usermod -aG pihole www-data

    - Open this file:
Code:
sudo nano -l /etc/nginx/nginx.conf

    - And uncomment line 64 (include /etc/nginx/sites-enabled/*):
Code:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    client_max_body_size 8M;

    ##
    # SSL Settings
    ##

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    #ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    ##
    # moOde UI server
    ##

    server {
        listen 80;

        location / {
            root /var/www;
            index index.html index.php;
            try_files $uri $uri/ /coverart.php;
        }

        location /imagesw/ {
            root /var/local/www;
        }

        # php-fpm
        location ~ \.php$ {
            root /var/www;
            fastcgi_pass unix:/run/php/php7.3-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include fastcgi_params;
        }
    }
}

    - Restart PHP and Nginx:
Code:
sudo systemctl restart php7.3-fpm.service
sudo systemctl restart nginx

    - At this point, you should can access to Pi-Hole:
Code:
http://pi.hole:8080/admin/

    - To finish, update moOde database:
Code:
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "DROP TRIGGER IF EXISTS ro_columns"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "UPDATE cfg_hash SET VALUE = '$(md5sum  /etc/nginx/nginx.conf | cut -d " " -f1)' WHERE PARAM = '/etc/nginx/nginx.conf'"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END;"

    - Reboot.


Hi TookaFace,

Is this the complete instructions? I am trying to install PiHole in Moode as well. Do I need to install the Nginx web server first? When I ran your first command line, I get the error "unable to update package cache. Please try sudo apt-get update"

I have moode 7.3 on RPi4B

Thanks.
Reply
#16
(09-29-2021, 03:43 AM)pyhfsg Wrote:
(11-30-2019, 04:37 PM)TookaFace Wrote: Just a little how-to for running Pi-Hole with moOde on Nginx web server.

Works for moOde 6.4 and higher

    - Install Pi-Hole:
Code:
curl -sSL https://install.pi-hole.net | bash

     - When prompted, answer Off to that question:
Code:
Do you wish to install the web server (lighttpd) and required PHP modules?
Off

    - Once the installation is complete, open this file:
Code:
sudo nano /etc/nginx/sites-available/default

    - Delete all contents and copy that instead:
Code:
server {
   listen 8080 default_server;
   listen [::]:8080 default_server;

   root /var/www/html;
   server_name _;
   autoindex off;
   error_page 404 /pihole/index.php;

   index pihole/index.php index.php index.html index.htm;

   location / {
       expires max;
       try_files $uri $uri/ =404;
   }

   location ~ \.php$ {
       include fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
       fastcgi_pass unix:/run/php/php7.3-fpm.sock;
       fastcgi_param FQDN true;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location /*.js {
       index pihole/index.js;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location /admin {
       root /var/www/html;
       index index.php index.html index.htm;
#        auth_basic "Restricted"; # For Basic Auth
#        auth_basic_user_file /etc/nginx/.htpasswd; # For Basic Auth
   }

   location ~ /\.ht {
       deny all;
   }
}

    - Set rights for Pi-Hole folder and add pihole user to www-data group:
Code:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo usermod -aG pihole www-data

    - Open this file:
Code:
sudo nano -l /etc/nginx/nginx.conf

    - And uncomment line 64 (include /etc/nginx/sites-enabled/*):
Code:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    client_max_body_size 8M;

    ##
    # SSL Settings
    ##

    #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    #ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    #include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

    ##
    # moOde UI server
    ##

    server {
        listen 80;

        location / {
            root /var/www;
            index index.html index.php;
            try_files $uri $uri/ /coverart.php;
        }

        location /imagesw/ {
            root /var/local/www;
        }

        # php-fpm
        location ~ \.php$ {
            root /var/www;
            fastcgi_pass unix:/run/php/php7.3-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include fastcgi_params;
        }
    }
}

    - Restart PHP and Nginx:
Code:
sudo systemctl restart php7.3-fpm.service
sudo systemctl restart nginx

    - At this point, you should can access to Pi-Hole:
Code:
http://pi.hole:8080/admin/

    - To finish, update moOde database:
Code:
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "DROP TRIGGER IF EXISTS ro_columns"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "UPDATE cfg_hash SET VALUE = '$(md5sum  /etc/nginx/nginx.conf | cut -d " " -f1)' WHERE PARAM = '/etc/nginx/nginx.conf'"
sudo sqlite3 "/var/local/www/db/moode-sqlite3.db" "CREATE TRIGGER ro_columns BEFORE UPDATE OF param, value, [action] ON cfg_hash FOR EACH ROW BEGIN SELECT RAISE(ABORT, 'read only'); END;"

    - Reboot.


Hi TookaFace,

Is this the complete instructions? I am trying to install PiHole in Moode as well. Do I need to install the Nginx web server first? When I ran your first command line, I get the error "unable to update package cache.Please try sudo apt-get update"

I have moode 7.3 on RPi4B

Thanks.


Quote:unable to update package cache.  Please try sudo apt-get update

Do that...
Code:
sudo apt-get update


Then restart "Install Pi-Hole"

Reply
#17
Nginx is already installed (moOde run on Nginx).

I tried the install on 7.4 without issues, but i've updated the procedure with sudo apt-get update at the beginning just in case  Smile
Reply
#18
Drone7, TookaFace,

Thanks for your reply. I did the "sudo apt-get update" but got the same error. Looks like the update of the repository was not applied per the error message below:

E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

Any idea how I can resolve this? I goolge a bit but has not found the solution yet.
Reply
#19
Ok, i got this resolved. I ran "sudo apt update" and answered "y" to accept the changes. I was able to start the pi-hole installation and went as far as verifying the IP address but the installation ended with:
[✓] Supported OS detected
[i] Checking for / installing Required dependencies for this install script...
[✓] Checking for git
[✓] Checking for iproute2
[✓] Checking for whiptail
[✓] Checking for ca-certificates

[i] SELinux not detected
[i] Using interface: eth0
[i] Using upstream DNS: Google (ECS) (8.8.8.8, 8.8.4.4)
[i] Your static IPv4 address: 192.168.86.77/24
[i] Your static IPv4 gateway: 192.168.86.1
packet_write_wait: Connection to 192.168.86.77 port 22: Broken pipe

Still troubleshooting
Reply
#20
problem resolved. I disabled the wifi on Moode and connect to ethernet and went restart the pi-hole installation, this time it went without a hitch. I am a happy camper.

Thanks to all of you.
Reply


Forum Jump: